Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105#!/usr/bin/env python3# ########################################################################### ## shebang: 1 ## ::: :::::::: ## model.py :+: :+: :+: ## +:+ +:+ +:+ ## By: jkrishna <jkrishna@student.42.fr> +#+ +:+ +#+ ## +#+#+#+#+#+ +#+ ## Created: 2026/10/10 13:20:17 by jkrishna #+# #+# ## Updated: 2026/10/27 14:12:22 by jkrishna ### ########.fr ## ## ########################################################################### #
import uuidfrom pydantic import BaseModel, Fieldfrom typing import List
def path_dict(path_abbr: str) -> str: path = { "DATA_PATH": "data/raw/vllm-0.10.1", "ip_ans_code_path": "data/datasets/AnsweredQuestions/dataset_code_public.json", "ip_ans_docs_path": "data/datasets/AnsweredQuestions/dataset_docs_public.json", "ip_unans_code_path": "data/datasets/UnansweredQuestions/dataset_code_public.json", "ip_unans_docs_path": "data/datasets/UnansweredQuestions/dataset_docs_public.json", "STUDENT_SEARCH_RESULTS_PATH": ("data/output/search_results/UnansweredQuestions" "/dataset_docs_public.json"), "OUTPUT_PATH": "data/output/search_results/UnansweredQuestions", "VECTOR_PATH": "data/vector" } return path[path_abbr]
class ChunkNode: def __init__( self, text: str, file_path: list, char_count: int, start_index: int, end_index: int, ): self.text: str = text self.file_path: list = file_path self.char_count: int = char_count self.start_index: int = start_index self.end_index: int = end_index
def push(code_line, file_path, start_index, end_index): return ( ChunkNode( code_line, file_path, len(code_line), start_index, end_index))
class MinimalSource(BaseModel): file_path: str first_character_index: int last_character_index: int
class UnansweredQuestion(BaseModel): question_id: str = Field( default_factory=lambda: str(uuid.uuid4())) question: str
class AnsweredQuestion(UnansweredQuestion): sources: List[MinimalSource] answer: str
class RagDataset(BaseModel): rag_questions: List[AnsweredQuestion | UnansweredQuestion]
class MinimalSearchResults(BaseModel): question_id: str question: str retrieved_sources: List[MinimalSource]
class MinimalAnswer(MinimalSearchResults): answer: str
class StudentSearchResults(BaseModel): search_results: List[MinimalSearchResults] k: int
class StudentSearchResultsAndAnswer(BaseModel): search_results: List[MinimalAnswer] k: int