|
import os |
|
import openai |
|
import gradio as gr |
|
|
|
|
|
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)}" |
|
|
|
|
|
demo = gr.Interface(fn=ask_agent, inputs="text", outputs="text", title="Nargis AI Gaia Agent") |
|
demo.launch() |
|
|