Spaces:
Sleeping
Sleeping
File size: 788 Bytes
f81a945 f46a883 f81a945 e0d91ab f81a945 f46a883 f81a945 f46a883 f81a945 f46a883 f81a945 f46a883 f81a945 f46a883 f81a945 e8b721e f81a945 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
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)
|