-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve: Research Agent Regex Parsing #469
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ONLY BETTER FORMATTING : NO MODIFICATIONS
src/agents/__init__.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JUST ADD THE NEW FILES
.gitignore
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IGNORE VSCODE & REORGANIZE A BIT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THE MAIN MODIFICATION
The parent class of all agents uses regex to efficiently parse LLM responses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ONLY FORMATING
src/agents/researcher/prompt.jinja2
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SMALL PROMPT MODIFICATION
To avoid getting more than 3 web search
src/agents/researcher/researcher.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ADAPT AGENT TO NEW MOTHER CLASS
Adaptation of the Research Agent to the changes made in the pull request
This is a big improvement when using ollama. Hopefully it's merged soon 👍 |
can you do this for all the agents? |
Of course ! I will fix the conflicts and extend the idea to all agents :) |
Thanx! Good job! |
still waiting to merge .... |
Work good as it is , but if we want to pass new variable to the render function , it will throw error . |
Description
Improvements
Resolved Issues
The list may not be exhaustive.
Related Pull Requests
Explanations
The current version of Devika expects to receive a specific JSON or MARKDOWN response format from LLMs in order to parse them correctly. Unfortunately, LLMs (especially smaller models like LLAMA3) do not always manage to respond perfectly to this task and bury their JSON between explanations, making their response impossible to parse. This pull request aims to use REGEX for better extraction of responses from LLMs.
Furthermore, in order to simplify this method and generalize it to all agents easily and without duplicating code, I propose in this pull request a new parent class for agents AgentTemplate which offers generic render & parse_answer methods that automatically extract the expected format from prompt.jinja2 and perform the expected validations. This modification significantly simplifies the code by reducing about 2/3 of the code for each agent, while avoiding repetition and limiting errors of the type "Invalid response from the model, trying again..."
For now, and as an example and test, I have only modified the RESEARCH agent, which now works perfectly with all LLMs I have tested: GPT4, CLAUDE OPUS, MISTRAL 8x7B, LLAMA3, and GEMMA. Once this pull request is validated, I am committed to adapting all the other agents in the same way.