Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save petrosDemetrakopoulos/581f2636df30b6ff60271f25d1d0f41d to your computer and use it in GitHub Desktop.
Save petrosDemetrakopoulos/581f2636df30b6ff60271f25d1d0f41d to your computer and use it in GitHub Desktop.
Customer query using AI Waterfall
def process_customer_query(query):
# Level 1: Check for FAQ matches
faq_match = check_faq_database(query)
if faq_match:
return faq_match
# Level 2: Intent classification with lightweight ML
intent, confidence = classify_intent_ml(query)
if confidence > 0.8:
return handle_known_intent(intent, query)
# Level 3: Few-shot with smaller model
if len(query.split()) < 20: # Simple queries
return handle_with_gpt35(query)
# Level 4: Full LLM reasoning for complex cases
return handle_with_gpt4(query)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment