Guide: Create an AI agent
A step-by-step guide to create an AI agent pipe on Langbase.
Prerequisites: Create an AI memory
This guide assumes you have already created an AI memory on Langbase using BaseAI. If you haven't, you can follow the Create an AI memory guide to create one.
In this guide, we will learn how to create an AI agent pipe on Langbase that will use OpenAI gpt-4o-mini
to answer user queries from documentation. We will:
- Create an AI Agent: Generate an AI agent pipe to interact with the AI memory.
- System prompts: Update system prompts to the AI agent.
- Attach AI Memory: Attach the AI memory to the AI agent.
- RAG prompts: Update RAG prompts to the AI agent.
Let's get started.
Step #1Create an AI Agent pipe
To get started, you'll need to create a free personal account on Langbase.com and verify your email address.
- When logged in, you can always go to pipe.new to create a new Pipe.
- Give your Pipe a name. Let's call it
ask-xyz-docs
. - Click on the
[Create Pipe]
button. And just like that, you have created an AI agent pipe.
Step #2System prompts
A system prompt sets the context, instructions, and guidelines for a language model before it receives questions or tasks. It helps define the model's role, personality, tone, and other details to improve its responses to user input.
Let's add the following system prompts to the AI agent pipe:
You are an AI chatbot designed to assist users with questions about {{company}}, which helps {{tagline}}. Your responses should be based strictly on the provided {{company}} documentation. Provide accurate and concise answers, avoiding any information not included in the documentation. If you are unsure of an answer, inform the user and suggest consulting the official {{company}} documentation or support for further assistance.
Always ensure your answers are clear, accurate, and derived directly from the {{company}} documentation. Include any relevant extra detail.
Step #3Attach AI Memory
Inside Pipe IDE, click on Memory. It will open a sidebar where you can select and attach the AI memory you created earlier. This will allow the AI agent to access the AI memory and provide accurate responses to user queries based on the documentation.
Step #4RAG prompt
A RAG prompt is a prompt that helps the AI model understand the context of the conversation. It is a prompt that is used to guide the AI model to generate responses that are relevant, accurate, and grammatically correct.
Let's update the RAG prompt of the AI agent pipe:
Below is the CONTEXT to answer the questions. ONLY use information from the CONTEXT to respond. The CONTEXT consists of multiple information chunks, each attributed to a specific source.
When providing responses:
1. Cite the source for each piece of information in brackets, e.g., [1].
2. At the end of your response, list all referenced sources in a new section, formatted as follows:
**Sources:**
[1] [Document Name](url)
[2] Document Name
- Use the filename given in the CONTEXT and remove prefixes like `src-app` or file extensions (e.g., `.mdx`).
- Capitalize words and insert spaces, e.g., `src-app-user-guide.mdx` becomes `User Guide`.
- If a URL is present, hyperlink the document name.
- If no URL is provided, list only the document name.
If the answer is not found in the CONTEXT, state:
"I could not find the answer in the provided CONTEXT. Please provide more details or ask a more specific question."
Feel free to customize the RAG prompt to suit your use case.
Next steps
Lastly, we will now setup the chatbot using Langbase components.