Spaces:
Running
Running
File size: 1,512 Bytes
8cfacd3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
"""Shared data models for the HF agent project"""
from datetime import datetime
from enum import Enum
from pydantic import BaseModel, Field
class Discussion(BaseModel):
"""Model for a discussion thread"""
title: str
url: str
topic_id: int
category: int
created_at: datetime
class QuestionAndSolution(BaseModel):
"""Model for a QA pair from a discussion"""
discussion_title: str
discussion_url: str
discussion_topic_id: int
discussion_category: int
discussion_created_at: datetime
thread: list[dict]
question: str
solution: str
class Correctness(str, Enum):
yes = "yes"
no = "no"
class JudgementResult(BaseModel):
"""Structured output for LLM judge evaluation"""
extracted_final_answer: str = Field(
description="The final exact/snippet answer extracted from the response"
)
reasoning: str = Field(
description="Explanation of why the answer is correct or incorrect"
)
correct: Correctness = Field(description="'yes' if correct, 'no' if incorrect")
confidence: int = Field(
description="Confidence score between 0 and 100", ge=0, le=100
)
class EvaluationResult(BaseModel):
"""Model for evaluation results including metadata"""
success: bool
judgement: JudgementResult | None = None
error: str | None = None
class EvaluatedQuestionAndSolution(QuestionAndSolution):
"""Model for a QA pair with its evaluation result"""
evaluation: JudgementResult
|