What you’ll build
A Q&A bot that:- Answers questions about any topic.
- Returns a confidence score with each answer.
- Flags low-confidence answers for follow-up.
Prerequisites
- A SeekrFlow API key, set as the
SEEKR_API_KEYenvironment variable - Python 3.8 or later
- The SeekrFlow SDK:
pip install seekrai
Build it
1
Set up the client
Create
qa_bot.py with the imports, configuration, and client.2
Write the prompt
Write a prompt that asks the model for an answer followed by a confidence rating
on its own line. Parsing depends on that
Confidence: marker. Keep it in the
instructions.3
Parse the response
Write a helper that splits the answer from the confidence rating and its
explanation.
4
Ask a question
Wrap the model call and parser in a function that prints the answer, its
confidence, and a follow-up hint when confidence is low. A low temperature keeps
answers more deterministic.
5
Ask a few questions
Run a few questions of varying difficulty to see the confidence score change.
6
Run the script
Run the finished script:Easy, well-known questions should come back with high confidence; obscure ones
should score lower and trigger the follow-up hint.
Next steps
- Keep context across turns. Hold a running
messageslist and include prior turns in each call to answer follow-up questions in context. - Tune the threshold. Adjust which confidence scores trigger the follow-up hint to match how cautious you want the bot to be.
- Ground the answers. Combine this with the New hire onboarding agent with citations so answers come from your own documents.