nexus-e-commerce / agent_setup.py
sadaqatyar's picture
Update agent_setup.py
f6de5a4 verified
from agents import AsyncOpenAI,set_default_openai_client,set_default_openai_api,set_tracing_disabled,Agent
def set_sdk_client(api_key: str, base_url: str):
"""
Set the Agents SDK client dynamically based on user input (Gemini or Groq).
"""
client = AsyncOpenAI(api_key=api_key, base_url=base_url)
set_tracing_disabled(disabled=True)
set_default_openai_client(client)
set_default_openai_api("chat_completions")
#This configures the agent setup
def create_agent(model_name, search_tool):
"""
Create an Agent with the specified model and search tool.
"""
agent = Agent(
name="NexusCustomerSupport",
model=model_name,
instructions = (
"You are a helpful assistant specialized in answering questions strictly based on the NEXUS document. "
"Always use the search_docs tool to retrieve relevant information from the document before responding. "
"If the user’s query is outside the scope of the document, politely state that you cannot provide an answer."
),
tools=[search_tool],
)
return agent