- Capture real-time user ratings (good/bad) on chatbot responses
- Log specific defects like grammatical errors, hallucinations, or ambiguity
- Run an interactive chatbot loop to collect feedback in real time
Step 1: Install Dependencies
An Orq.ai account is required before starting. If not signed up yet, create an account first. A Google Colab file is also available to copy, replace the API key, and run immediately. Start by installing the required packages to use the Orq.ai SDK:Step 2: Identity Tracking (Optional)
Identities in Orq.ai help track user interactions and API usage across an application. They can represent users, teams, or projects and enable better analytics and budget management. Create an Identity through AI Studio:- Go to Identities in the workspace
- Click Create an Identity
- Add the identity details (name, email,
externalId) - Set optional metadata and budget limits
Step 3: Set Up the Orq Client
Set up the Orq.ai client using the API key. Replace the placeholder with the actual API key.Step 4: Create a Knowledge Base
Create a knowledge base via the SDK, upload a document (replacedocs.pdf with the product documentation file to be used by the FAQ bot), and attach it as a datasource. The agent created in the next step will automatically retrieve relevant chunks from this knowledge base at query time.
Python
Step 5: Create the Agent
Create the FAQ agent via the SDK, attaching the knowledge base from Step 4. The agent instructions define the behavior: answer only from the knowledge base, express uncertainty when unsure.Python
Step 6: Define the Interaction Function
The bot needs a function to send user messages to the agent and return the response text and trace ID. The trace ID is needed for feedback logging in Step 7. This function is called inside the chatbot loop in Step 7.Step 7: Run the FAQ Bot
In a real deployment, feedback would be collected through front-end buttons (e.g., thumbs-up/down, dropdowns, or action buttons). For demonstration purposes, we simulate this process in the notebook using text-based inputs. The feedback loop works in two stages:- User Rating: After each response, users mark it as good or bad.
- Defect Classification: For bad responses, users specify the issue (grammatical, hallucination, off-topic, etc.) for targeted improvements.
Next Steps
A structured feedback loop is now in place for the FAQ bot, ensuring continuous learning and response improvement. To take it further:- Integrate interaction tracking: Link front-end actions (copied, saved, deleted, shared) to feedback logging, allowing the bot to learn without requiring explicit user input.
- Create annotated datasets in Orq.ai: Use feedback as a selection method to build curated datasets for evaluation. Run experiments to see if updates to prompts, models, parameters, or the knowledge base improve performance and response quality.