Skip to content

Implement Context-Based Response Validation Logic #310

@nuwangeek

Description

@nuwangeek

Description

Implement logic to handle queries that can be answered from the current user query and conversation history. This includes greeting detection and context-based response generation.

Objective

  • Detect greetings (hello, hi, goodbye, thanks) and provide friendly responses
  • Analyze conversation history to answer follow-up questions
  • Use LLM to intelligently determine if query references conversation context

Technical Requirements

3.1 Greeting Detection

Supported Languages: Estonian (et), English (en)

Greeting Types:

  • hello: Tere, Hello, Hi, Good morning
  • goodbye: Nägemist, Bye, Goodbye, See you
  • thanks: Tänan, Thank you, Thanks
  • casual: Hei, Hey, Moi

Response Generation: Use LLM to generate contextually appropriate responses in the same language

3.2 Context Analysis

Input: User query + conversation history (last 10 turns)

LLM Task:

  1. Check if query is a greeting → respond appropriately
  2. Check if query references conversation history → extract answer
  3. Otherwise → fallback to RAG workflow

Output Format:

{
  "is_greeting": true/false,
  "can_answer_from_context": true/false,
  "answer": "response text or null",
  "reasoning": "brief explanation"
}

Acceptance Criteria

  • Implement ContextAnalyzer with LLM-based greeting detection
  • Implement conversation history formatting (last 10 turns)
  • Implement ContextWorkflowExecutor with streaming support
  • Add greeting response constants (ET/EN)
  • Add fallback to RAG when context cannot answer
  • Add cost tracking for context check LLM calls
  • Unit tests for greeting detection
  • Unit tests for context-based responses
  • Integration tests for context workflow

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions