-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
questionQuestion about using the SDKQuestion about using the SDK
Description
I have written this function to use the OpenAI Agent SDK along with Gradio. I would like to pass in the history. I learned that you can use the result.to_input_list() function to obtain an input list that concatenates the original input you provided. However, how does this work with the code below?
async def chat(message, history):
try:
# Make an agent with name, instructions, model
agent = Agent(
name="ADR Writer",
instructions=system_prompt,
model=OpenAIChatCompletionsModel(
model="gpt-4o-mini",
openai_client=openai_client
),
tools=tools
)
result = await Runner.run(agent, message)
return result.final_output
except OpenAIError as e:
print(f"OpenAI API Error: {str(e)}")
except Exception as e:
print(f"An unexpected error occurred: {str(e)}")
gr.ChatInterface(fn=chat, type="messages").launch()
Metadata
Metadata
Assignees
Labels
questionQuestion about using the SDKQuestion about using the SDK