File size: 721 Bytes
10e9b7d 57bc882 10e9b7d 57bc882 e80aab9 57bc882 e80aab9 57bc882 e80aab9 57bc882 7d65c66 57bc882 3c4371f 57bc882 |
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 |
import os
import openai
import gradio as gr
# Set your API key from Hugging Face secret
openai.api_key = os.environ.get("OPENAI_API_KEY")
def ask_agent(question):
try:
response = openai.ChatCompletion.create(
model="gpt-4o",
messages=[
{"role": "system", "content": "You are a helpful, concise AI agent."},
{"role": "user", "content": question}
],
temperature=0.3,
)
return response['choices'][0]['message']['content'].strip()
except Exception as e:
return f"[ERROR] {str(e)}"
# Gradio UI
demo = gr.Interface(fn=ask_agent, inputs="text", outputs="text", title="Nargis AI Gaia Agent")
demo.launch()
|