Spaces:
Runtime error
Runtime error
| import os | |
| import openai | |
| openai.api_key = os.getenv("OPENAI_API_KEY") | |
| openai.Model.list() | |
| import gradio as gr | |
| from openai.api_resources import engines | |
| openai.api_key = "OPENAI_API_KEY" | |
| model_engine = "gpt-3.5-turbo" | |
| def chatbot(prompt): | |
| completions = openai.Completion.create( | |
| engine=model_engine, | |
| prompt=prompt, | |
| max_tokens=100, | |
| n=1, | |
| stop=None, | |
| temperature=0.5, | |
| ) | |
| response = completions.choices[0].text.strip() | |
| return response | |
| iface = gr.Interface( | |
| fn=chatbot, | |
| inputs=gr.inputs.Textbox(lines=5, placeholder="Enter your message here..."), | |
| outputs="text", | |
| title="Chatbot", | |
| description="A chatbot using OpenAI's GPT-3.5-turbo", | |
| ) | |
| iface.launch() | |