from cerevox import Hippohippo = Hippo(api_key="your-api-key")# Ask a questionanswer = hippo.submit_ask( chat_id="chat_123", question="How do I authenticate users in the API?")# Access the responseprint(f"Answer: {answer.response}")print(f"Confidence: {answer.confidence_score}")print(f"Sources: {len(answer.sources)}")
# Get the 3rd question/answer from chatask = hippo.get_ask_by_index( chat_id="chat_123", index=2 # 0-indexed)print(f"Q: {ask.question}")print(f"A: {ask.response}")
# First questionanswer1 = hippo.submit_ask( chat_id, "What are the API authentication methods?")print(f"A1: {answer1.response}")# Follow-up (references "methods" from Q1)answer2 = hippo.submit_ask( chat_id, "Which one is most secure?" # Understands context)print(f"A2: {answer2.response}")# Another follow-up (references "secure method" from Q2)answer3 = hippo.submit_ask( chat_id, "How do I implement it?" # Knows what "it" refers to)print(f"A3: {answer3.response}")
Context memory: Last 10 Q&A exchanges are used for context in follow-up questions.
questions = [ "What is the API rate limit?", "What's the refund policy?", "What programming languages are supported?"]
Performance: Highest accuracy (99.5%+ with clear documentation)
How-To Questions
Best for: Step-by-step instructions
Copy
questions = [ "How do I reset my password?", "How can I integrate with Stripe?", "How do I export data to CSV?"]
Performance: Excellent when docs contain clear procedures
Comparison Questions
Best for: Comparing options or features
Copy
questions = [ "What's the difference between Basic and Pro plans?", "How does REST compare to GraphQL in our API?", "Which authentication method is most secure?"]
Performance: Good when comparison info exists in docs
Summary Questions
Best for: Synthesizing information
Copy
questions = [ "What are the main features of Product X?", "Summarize the key risks in this contract", "What were the Q3 revenue highlights?"]
Performance: Good for overview questions across multiple sources
Yes/No Questions
Best for: Quick verification
Copy
questions = [ "Does the API support webhooks?", "Can I export data to Excel?", "Is there a mobile app?"]
✅ “What is the API rate limit for Pro plan users?”
❌ “Tell me about limits”Specific questions get specific answers
Use Natural Language
✅ “How do I reset my password?”
❌ “password reset procedure documentation”Write questions as you’d ask a person
One Question at a Time
✅ “What is the refund policy?”
❌ “What’s the refund policy and cancellation process and payment methods?”Multiple questions → Ask separately for better answers
Provide Context if Needed
✅ “In the REST API, how do I authenticate?”
❌ “How authenticate?” (ambiguous)Context helps when docs cover multiple systems
answer = hippo.submit_ask(chat_id, question)if answer.confidence_score >= 0.9: print("✅ High confidence - Answer is very reliable")elif answer.confidence_score >= 0.7: print("⚠️ Medium confidence - Check sources to verify")else: print("⚠️ Low confidence - Information may not be in documents") print("Consider:") print("- Rephrasing the question") print("- Adding relevant documents") print("- Checking if info exists in uploaded files")
answer = hippo.submit_ask(chat_id, question)if answer.confidence_score < 0.7: print("Low confidence - verifying sources...") for source in answer.sources: print(f"Check: {source.file_name}, page {source.page_number}")
Always check sources for low-confidence answers.
Rephrase if Needed
Copy
# First attemptanswer1 = hippo.submit_ask(chat_id, "What's the policy?")if answer1.confidence_score < 0.7: # Rephrase with more context answer2 = hippo.submit_ask( chat_id, "What is the company's refund policy for products?" )
More specific questions → Better answers
Add Documents if Information Missing
Copy
answer = hippo.submit_ask(chat_id, "What is the SLA?")if len(answer.sources) == 0: print("No sources found - may need to upload SLA document") # Upload missing documentation hippo.upload_file(folder_id, "service-level-agreement.pdf") # Ask again answer = hippo.submit_ask(chat_id, "What is the SLA?")
Use Follow-ups for Clarification
Copy
# Initial questiona1 = hippo.submit_ask(chat_id, "How do I authenticate?")# If answer mentions multiple methods, follow upa2 = hippo.submit_ask(chat_id, "Which method is recommended?")# Further clarificationa3 = hippo.submit_ask(chat_id, "Can you show an example?")