| [Root ↑] | src \ endpoints \ hypo69 | Русский |
Вот обновленный текст файла README.md для модуля code_assistant, который описывает все скрипты (code_assistant.py, make_summary.py, onela_bot.py, bot_handlers.py):
.. module:: src.endpoints.hypo69.code_assistant| [Root ↑] | src \ endpoints \ hypo69 | English |
The Code Assistant module is a set of tools designed to interact with Gemini and OpenAI models for processing project source code. It performs tasks such as generating documentation, code review, and test generation based on specified files. Additionally, it includes scripts for creating a SUMMARY.md file for documentation compilation and a Telegram bot for handling code-related tasks.
- File Reading: Reads code from
.pyandREADME.MDfiles in specified directories. - Model Interaction: Sends code to models for tasks like documentation generation or error checking.
- Result Generation: Saves model responses in designated directories for each role.
- SUMMARY.md Generation: Recursively traverses a directory to create a
SUMMARY.mdfile for documentation compilation. - Language Filtering: Supports filtering files by language (
ruoren).
- Telegram Bot: A bot for handling code-related tasks, such as sending code snippets for review or generating documentation.
- Bot Handlers: Contains handlers for processing bot commands and messages.
- Models: Uses Gemini and OpenAI models for processing requests.
- Prompts: Reads prompts from files in
src/ai/prompts/developer/(e.g.,doc_writer_en.md). - Files: Processes
.pyandREADME.MDfiles in specified directories.
python code_assistant.py --settings settings.jsonpython code_assistant.py --role doc_writer --lang ru --models gemini openai --start_dirs /path/to/dir1 /path/to/dir2python code_assistant.py --role code_checker --lang en --models gemini --start_dirs /path/to/dirpython code_assistant.py --role doc_writer --lang en --models openai--settings: Path to a JSON file with settings. Loads parameters from the file.--role: The role of the model for the task (e.g.,doc_writer,code_checker).--lang: The language for the task (e.g.,ruoren).--models: List of models to initialize (e.g.,gemini,openai).--start_dirs: List of directories to process (e.g.,/path/to/dir1).
- File Reading: Searches for
.pyandREADME.MDfiles in specified directories. - Prompt Loading: Loads role-specific prompts from
src/ai/prompts/developer/. - Request Processing: Forms requests based on loaded files and sends them to models.
- Response Saving: Saves model responses in directories corresponding to the role and model (e.g.,
docs/raw_rst_from_<model>/<lang>/).
Configure exceptions for files and directories using parameters:
exclude_file_patterns: List of regex patterns to exclude files.exclude_dirs: List of directories to exclude.exclude_files: List of files to exclude.
Logs are saved using the logger library and contain information about the file processing and model responses.
- Gemini API: Requires an API key for the Gemini model.
- OpenAI API: Requires an API key for the OpenAI model.
-
Update
code_assistant.json:- Add the new role to the list of roles:
"roles": [ "code_checker", ... ]
- Alternatively, exclude it in
"exclude-roles".
- Add the new role to the list of roles:
-
Add Role to Translations:
- Update the
translations/translations.jsonfile with the new role.
- Update the
-
Create a System Prompt:
- Add a new system prompt in
ai/prompts/developer/.
- Add a new system prompt in
-
Create a Command Instruction:
- Add a new command instruction in
instructions/.
- Add a new command instruction in
This README.md provides a comprehensive overview of the code_assistant module, its scripts, and how to use them effectively.