Spaces:
Running
Running
File size: 715 Bytes
597a99a 8ccedd7 20cba25 8ccedd7 4814e56 8ccedd7 4578759 8ccedd7 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
from openai import OpenAI
import gradio
import os
api_key = os.getenv("OPENAI_API_KEY")
client = OpenAI(api_key=api_key)
messages = [{"role": "system", "content": "You are an expert in the assistance of guiding people to a better solution."}]
def CustomChatGPT(user_input):
messages.append({"role": "user", "content": user_input})
response = client.chat.completions.create(
model = "gpt-4o",
messages = messages
)
ChatGPT_reply = response.choices[0].message.content
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply
demo = gradio.Interface(fn=CustomChatGPT, inputs = "text", outputs = "text", title = "chaiT")
demo.launch(share=True)
|