File size: 1,130 Bytes
55a19ee
4d65ce5
55a19ee
 
 
 
 
 
 
 
4d65ce5
f6de5a4
 
55a19ee
 
 
 
 
 
 
 
 
 
 
 
 
4d65ce5
55a19ee
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
26
27
28
29
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