Conversation
Samoed
reviewed
Mar 28, 2026
There was a problem hiding this comment.
Лучше сделать pydantic модель для валидации модели
|
|
||
| PROJECT_ROOT = Path(__file__).resolve().parent.parent | ||
|
|
||
| with open(PROJECT_ROOT / "config.yaml") as f: |
There was a problem hiding this comment.
Зачем в каждом файле парсить конфиг заново?
| print(f"LLM error ({current_model}, attempt {attempt + 1}/{max_retries + 1}): {e}") | ||
| if attempt < max_retries: | ||
| sleep_time = backoff_base ** (attempt + 1) | ||
| print(f" Retrying in {sleep_time:.0f}s...") |
Comment on lines
+69
to
+74
| raw = llm_call_with_retry( | ||
| self.client, self.model, messages, | ||
| fallback_models=self.fallback_models, | ||
| max_retries=self.max_retries, | ||
| backoff_base=self.backoff_base, | ||
| ) |
There was a problem hiding this comment.
Лучше использовать response_format, чтобы модель генерировала в нужном формате
Comment on lines
+89
to
+96
| return { | ||
| "genre": parsed.get("genre"), | ||
| "mood": parsed.get("mood"), | ||
| "max_duration": parsed.get("max_duration"), | ||
| "min_year": parsed.get("min_year"), | ||
| "min_rating": parsed.get("min_rating"), | ||
| "semantic_query": parsed["semantic_query"], | ||
| } |
Comment on lines
+53
to
+64
| conn.execute(""" | ||
| CREATE TABLE IF NOT EXISTS logs ( | ||
| request_id TEXT PRIMARY KEY, | ||
| timestamp REAL, | ||
| user_query TEXT, | ||
| parsed_query TEXT, | ||
| retrieved_movie_ids TEXT, | ||
| llm_response TEXT, | ||
| latency_ms REAL, | ||
| feedback TEXT | ||
| ) | ||
| """) |
There was a problem hiding this comment.
Почему не использовали sqlalchemy для таблиц и запросов?
| movie_ids: list[str], response: str, latency_ms: float): | ||
| """Log request to SQLite.""" | ||
| try: | ||
| conn = sqlite3.connect(str(self.db_path)) |
There was a problem hiding this comment.
Почему не использовать общий connection?
| except Exception as e: | ||
| print(f"Feedback save error: {e}") | ||
|
|
||
| def _clean_json_response(self, text: str) -> str: |
There was a problem hiding this comment.
Лучше использовать pyproject и туда добавить линтеры и форматтеры
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ДЗ2: MVP проекта CineMatch
Артефакты
src/— исходный код RAG-пайплайна (query_analyzer, retrieval, rag, hallucination, llm_utils, app)scripts/— скрипты подготовки данных и оценки (ingest, build_index, evaluate)config.yaml,prompts.yaml— конфигурация системы и промптыrequirements.txt— зависимостиreports/hw2_report.md— отчёт по этапуЧто реализовано
5-этапный RAG-пайплайн:
Запуск