Spaces:
Runtime error
Runtime error
Download app.py from amritsolar/NEWGRADIOAI: direct link, hf CLI and curl.
- Browser
- Download file 788 Bytes
-
https://huggingface.co/spaces/amritsolar/NEWGRADIOAI/resolve/main/app.py
- Command line
-
hf download hf://spaces/amritsolar/NEWGRADIOAI/app.py
-
curl -L -o app.py https://huggingface.co/spaces/amritsolar/NEWGRADIOAI/resolve/main/app.py
788 Bytes
| import openai | |
| import gradio | |
| openai.api_key = "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" | |
| messages = [{"role": "system", "content": "YOU ARE THE BEST DEVELOPER "}] | |
| def CustomChatGPT(YO_U): | |
| try: | |
| messages.append({"role": "user", "content": YO_U}) | |
| response = openai.ChatCompletion.create( | |
| model="gpt-3.5-turbo", | |
| messages=messages | |
| ) | |
| #ChatGpt_Reply# | |
| ANSWER = response["choices"][0]["message"]["content"] | |
| messages.append({"role": "assistant", "content": ANSWER}) | |
| return ANSWER | |
| except Exception as e: | |
| return f"An error occurred: {str(e)}" | |
| demo = gradio.Interface(fn=CustomChatGPT, inputs="text", outputs="text", title="BEST DEVELOPERS Developed By AmritTech") | |
| demo.launch(share=False) | |