Skip to main content

Connecting a RAG agent to your tenant

In this guide, we will learn how to connect the simple agent built in the Tutorial First RAG Agent to a specific index of your tenant. In this way, you will be able to create your own RAG pipelines backed by the Zeta Alpha Search API which can serve the data you ingested for your tenant.

Prerequisites

Before you begin, make sure you have configured the my_rag_agent as shown in the First RAG Agent tutorial.

Also, make sure your documents have been successfully ingested to your tenant's index through the Ingestion API.

Assuming you have a setup similar to the following for your tenant, you can proceed with the guide:

TENANT=my-tenant
INDEX_ID=my-index-id
ZA_API_KEY=my-zav-api-key

Step 1: Connect the agent to your tenant

Go to your <agents project> directory where you have already configured the agent my_rag_agent.

You can now open the agent_setups.json and add the tenant-specific information under the agent_configuration field:

{
"agent_identifier": "my_rag_agent",
"agent_name": "my_rag_agent",
"llm_client_configuration": {
"vendor": "openai",
"vendor_configuration": {},
"model_configuration": {
"name": "gpt-4o-mini",
"type": "chat",
"temperature": 0.0
}
},
"agent_configuration": {
"tenant": "my-tenant",
"index_id": "my-index-id"
}
}

You also need to enhance the secret env/agent_setups.json with the API key for calling the Zeta Alpha Search API:

{
"agent_identifier": "my_rag_agent",
"llm_client_configuration": {
"vendor_configuration": {
"openai": {
"openai_api_key": "my-openai-api-key",
"openai_org": ""
}
}
},
"agent_configuration": {
"x_auth": "my-zav-api-key"
}
}
note

Since the retriever (ZAVRetriever) is a dependency of the agent (MyRAGAgent), the agent configuration will be also passed to the retriever as described in How to Configure Agents.

In this way, the retriever now points to your tenant's index.

Step 2: Running Your Agent Locally

Running in the UI

You can run and test your agent in the UI by running the following command:

rag_agents dev --reload

Here you can chat with your agent and test its functionality.

Running as an API

Alternatively, you can serve your agent as an API by running the following command:

rag_agents serve --reload
info

For running the agent as an API, you do not have to configure the agent as shown in Step 1, since the tenant-specific information can be passed directly in the API request as shown below.

To test your agent, you can use the Swagger UI available at http://localhost:8000/docs or send a POST request to the /chats/responses endpoint. Here's the example using curl:

curl -X POST "http://localhost:8000/v1/chats/responses?tenant=my-tenant&index_id=my-index-id" \
-H "Content-Type: application/json" \
-H "X-Auth: my-zav-api-key" \
-d '{
"agent_identifier": "my_rag_agent",
"conversation": [
{"sender": "user", "content": "What is a transformer?"}
]
}'

You should receive a response from your agent with the answer to your query.

If you have any questions or run into issues, feel free to reach out to our support team.