openllmetry icon indicating copy to clipboard operation
openllmetry copied to clipboard

chore(sample-app): add medical doctor Q&A example with Traceloop instrumentation

Open nirga opened this issue 2 months ago • 1 comments

Summary

This PR adds a comprehensive medical doctor Q&A example to the sample-app that demonstrates OpenLLMetry/Traceloop instrumentation with OpenAI's GPT models.

Features Added

  • Medical Q&A Application (medical_qa_example.py):

    • Single question mode for interactive consultations
    • Batch mode processing 20 predefined medical questions
    • Professional medical persona with appropriate disclaimers and safety warnings
    • Comprehensive error handling and result saving
  • Traceloop Instrumentation:

    • @workflow decorators for main consultation flows (single and batch modes)
    • Automatic OpenAI API call instrumentation with request/response tracing
    • Token usage metrics and performance monitoring
    • Error tracking and observability
  • Medical Safety Features:

    • Evidence-based medical advice with professional disclaimers
    • Recommendations to consult healthcare providers for serious symptoms
    • Clear warnings for emergency situations requiring immediate attention
    • Ethical guidelines avoiding specific diagnoses without examination
  • Documentation:

    • Comprehensive README_medical_qa.md with setup and usage instructions
    • 20 sample medical questions covering common health topics
    • Example results showing proper medical responses with disclaimers
    • Updated main sample-app README

Sample Questions Covered

  • Symptoms and conditions (flu, diabetes, heart attack signs, concussion)
  • Preventive care (vaccines, physical exams, immune system boosting)
  • Emergency situations (chest pain, dangerous fever levels)
  • General health guidance (sleep, hydration, stress management)

Technical Implementation

  • Clean Architecture: Functional approach with proper separation of concerns
  • Code Quality: Passes all flake8 linting checks
  • Flexibility: Supports both environment variables and command-line API key input
  • Extensibility: Easy to add new medical questions or modify responses

Usage Examples

# Single question mode
poetry run python sample_app/medical_qa_example.py --mode single --question "What are flu symptoms?"

# Batch processing with result saving
poetry run python sample_app/medical_qa_example.py --mode batch --save

Safety Notice

⚠️ This is a demonstration example for technical purposes. The medical responses should not replace professional medical advice and include appropriate disclaimers.

Test Plan

  • [x] Verify script runs without errors in both single and batch modes
  • [x] Confirm proper Traceloop instrumentation and span generation
  • [x] Validate medical responses include appropriate disclaimers
  • [x] Test error handling with invalid API keys
  • [x] Check code passes flake8 linting standards
  • [x] Verify documentation is comprehensive and accurate

🤖 Generated with Claude Code


[!IMPORTANT] Adds a medical Q&A example to the sample app with Traceloop instrumentation, featuring single and batch modes, comprehensive documentation, and safety disclaimers.

  • Features:
    • Adds medical_qa_example.py for a medical Q&A chatbot with single and batch modes.
    • Includes 20 predefined medical questions for batch processing.
    • Implements Traceloop instrumentation for OpenAI API calls with @workflow decorators.
  • Documentation:
    • Adds README_medical_qa.md with setup and usage instructions.
    • Updates README.md to include the new medical Q&A example.
  • Safety:
    • Provides medical disclaimers and advises consulting healthcare providers for serious symptoms.
  • Technical:
    • Uses OpenAI's GPT models for generating responses.
    • Supports environment variables and command-line input for API keys.
    • Passes flake8 linting checks.

This description was created by Ellipsis for c720b403b20f2718b2626d383768719e71702614. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Added a Medical Doctor Q&A sample app with interactive single-question and batch modes, optional result saving, and built-in observability via OpenTelemetry/Traceloop.
  • Documentation

    • Revamped sample app README with examples, Poetry-based usage, and pointers to additional frameworks/tools.
    • Added a dedicated Medical Q&A guide covering setup, usage, safety notes, and tracing overview.
  • Chores

    • Added required dependencies for the sample.
    • Included a static dataset of sample medical Q&A results.

nirga avatar Sep 16 '25 09:09 nirga