I am going to load to you my python project to find and fix all the bugs. Goal of this project is to build a system that replaces human teck support agents for FlekSt0re service. It contains ~3200 lines of code and has this structure:
app/
│ ├── .env
│ ├── .py
│ ├── config.py
│ ├── data.json
│ ├── database.py
│ ├── emulate_and_evaluate.py
│ ├── evaluation_results.csv
│ ├── freescout_data.json
│ ├── main.py
│ ├── requirements.txt
│ ├── test_playground.py
│ ├── api/
│ │ ├── .py
│ │ ├── routes.py
│ │ ├── routes_freescout.py
│ │ ├── /
│ │ │ ├── .cpython-310.pyc
│ │ │ ├── routes.cpython-310.pyc
│ │ │ ├── routes_freescout.cpython-310.pyc
│ ├── bot/
│ │ ├── .py
│ │ ├── telegram_bot.py
│ │ ├── /
│ │ │ ├── .cpython-310.pyc
│ │ │ ├── telegram_bot.cpython-310.pyc
│ ├── services/
│ │ ├── .py
│ │ ├── agent_service.py
│ │ ├── freescout_service.py
│ │ ├── image_service.py
│ │ ├── memory_service.py
│ │ ├── rag_service.py
│ │ ├── template_service.py
│ │ ├── /
│ │ │ ├── .cpython-310.pyc
│ │ │ ├── agent_service.cpython-310.pyc
│ │ │ ├── freescout_service.cpython-310.pyc
│ │ │ ├── image_service.cpython-310.pyc
│ │ │ ├── memory_service.cpython-310.pyc
│ │ │ ├── rag_service.cpython-310.pyc
│ │ │ ├── template_service.cpython-310.pyc
│ ├── tools/
│ │ ├── .py
│ │ ├── agent_tools.py
│ │ ├── /
│ │ │ ├── .cpython-310.pyc
│ │ │ ├── agent_tools.cpython-310.pyc
│ ├── /
│ │ ├── .cpython-310.pyc
│ │ ├── config.cpython-310.pyc
│ │ ├── database.cpython-310.pyc
│ │ ├── emulate_and_evaluate.cpython-310.pyc
The idea of code is use OpenAI models like GPT-4.1-mini to generate answers in Telegram and FreeScout including answers to images and including using some data from FlexSt0re API (like device data by UDID) and RAG. Also it contains playground for testing (I have dataset of all previous conversations between human agents and customers I wrote code that uses OpenAI model to emulate human using this conversations and judge LLM agent to validate and visualize result)
Create plan of testing and say what files or information do you need first.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
What a behemoth of a project! I'm excited to help you tame the beast. Given the complexity and size of your codebase (~3200 lines), we'll need a structured approach to identify and fix bugs. Here's a Testing Plan divided into phases. I'll outline what files/information I need at each stage. Buckle up!
Phase 1: Understand the Project Structure, Dependencies, and Requirements (Time: 1-2 hours)
Before diving into code, I need to grasp the overall architecture, tech stack, and external dependencies. Please provide:
requirements.txt: This file will tell me about the Python libraries and versions used in the project.
.env file (redacted): Share the structure of the .env file (variable names, not values) to understand environment variables used throughout the project (e.g., API keys, DB connections). Do not share actual values for security reasons.
config.py: This will reveal how environment variables are loaded and if there are any configuration defaults or overrides.
High-level overview of FlexSt0re API: Share API documentation (or key endpoints, request/response formats) for:
Device data retrieval by UDID.
Any authentication mechanisms.
OpenAI Model specifics:
Which GPT-4 model variant is used (e.g., gpt-4-1106-preview, gpt-4-vision-preview)?
Are there any specific prompts, system messages, or fine-tuned models employed?
Brief description of RAG (Retrieval-Augmented Generation) implementation: How is RAG integrated? Is it a custom solution or using a library like LangChain or LlamaIndex?
Deliverables from me at the end of Phase 1:
A mind map or text summary of the project's architecture.
List of external dependencies (APIs, services) and potential points of failure.
Initial hypothesis on where bugs might lurk (based on common pitfalls in similar projects).
api/routes.py & api/routes_freescout.py: API endpoint definitions for:
FreeScout interactions (if applicable).
Potential webhook receivers for incoming queries.
services/agent_service.py: The brain of the operation – how does the "agent" logic work?
Interaction with OpenAI models.
RAG data retrieval and processing.
FlexSt0re API data integration.
data.json & freescout_data.json: Samples or structure of these data files. What kind of information do they hold, and how is it used?
Key functions from tools/agent_tools.py: Any utility functions crucial for the agent's decision-making or response generation.
Deliverables from me at the end of Phase 2:
Sequence diagrams or flowcharts for:
A typical Telegram user interaction.
An API request lifecycle (if applicable).
Identification of data touchpoints: Where data from .json files, FlexSt0re API, and RAG converges.
List of functions/methods that seem high-risk for bugs (e.g., complex conditionals, external API calls).
Phase 3: Emulation, Evaluation, and Testing Framework (Time: 2 hours)
Your emulation and evaluation framework is unique and crucial for validating the LLM agent. I need to understand:
emulate_and_evaluate.py: The core script that:
Emulates human agents using historical conversations.
Evaluates LLM responses against these emulated interactions.
evaluation_results.csv (sample rows): See the output structure – what metrics are being tracked (e.g., accuracy, response time, user satisfaction score)?
test_playground.py: Your manual testing playground. How do you currently test hypotheses or debug specific scenarios?
Dataset details: Briefly describe the historical conversation dataset (size, format, fields like user_query, human_agent_response, context etc.).
Deliverables from me at the end of Phase 3:
A critique of the current evaluation methodology:
Potential biases in emulating human agents.
Suggestions for additional metrics or test cases.
Ideas on automating regression tests using parts of this emulation framework.
Phase 4: Deep Dive into Bug Hunting (Time: Ongoing, dependent on findings)
With the above understanding, we'll start executing the code in various scenarios, using:
Your test_playground.py as a baseline.
Creating new test cases based on the flows identified.
Logging and tracing important events (e.g., API calls, model responses, errors).
At this stage, I'll request:
Specific logs or stack traces when errors occur.
Permission to run the application myself (if feasible) to replicate issues.
Iteratively provide targeted code snippets where I suspect bugs.
Tools We'll Use:
pdb or breakpoint() for interactive debugging.
logging module to enhance traceability.
pytest (if not already used) for structuring test cases.
OpenAI's tiktoken (if needed) to inspect tokenization issues.
Estimated Total Time: 8-12 hours (spread across phases), depending on:
Complexity of actual bugs found.
How quickly we can replicate issues.
Extent of refactoring (if legacy code patterns are hindering readability).
Pre-requisites Before We Begin:
Ensure your .env has placeholder values (not real secrets).
Share __pycache__ folders are okay to ignore; we'll regenerate them.
If any parts of the code are third-party modified libraries, share those diffs.
Once I have the files and information requested in Phase 1, I'll start analyzing and provide feedback within 24 hours. We'll take it from there, phase by phase.
Ready to start? Please upload or share links to the required files from Phase 1. Let's squash those bugs!