Spaces:
Runtime error
Runtime error
File size: 679 Bytes
ce86582 4e06412 9867ef4 4e06412 9867ef4 d4c46b9 9867ef4 a565320 9867ef4 c2e72a9 86a5a65 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import gradio as gr
from huggingface_hub import secrets
import openai
# Retrieve the API key from the Secrets Manager
openai.api_key = secrets.get("api_key")
messages = [{"role": "system", "content": "you are chatGPT"}]
def GPTBhai(user_input):
messages.append({"role": "user", "content": user_input})
response = openai.ChatCompletion.create(
model = "gpt-3.5-turbo",
messages = messages
)
ChatGPT_reply = response["choices"][0]["message"]["content"]
messages.append({"role": "assistant", "content": ChatGPT_reply})
return ChatGPT_reply
iface = gr.Interface(fn=GPTBhai, inputs = "text", outputs = "text", title = "bhAI")
iface.launch() |