# 1. Create an agent
def create_agent():
url = f"{BASE_URL}/agent"
data = {
"name": "my-agent",
"prompt": "You are a helpful assistant that provides accurate information based on your knowledge base."
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
return response.json()
# 2. Add knowledge (Q&A pairs)
def add_knowledge(agent_id, question, answer):
url = f"{BASE_URL}/q-and-a"
data = {
"question": question,
"answer": answer,
"agent_id": agent_id
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
return response.json()
# 3. Chat with the agent
def chat(agent_id, message, conversation_id):
url = f"{BASE_URL}/chat/{agent_id}"
data = {
"user_message": message,
"conversation_uuid": conversation_id
}
response = requests.post(url, headers=headers, json=data)
response.raise_for_status()
return response.json()