Add json parser tool to be used by zero shot agent
What does this MR do and why?
Add JsonReader to the ZeroTool agents.
What is missing:
Current state of work (2023-06-01, 19:50 UTC)
- We could use more specs. @cablett did a fantastic job yesterday!
- I need to put the remarks from George in
- current implementation is compatible with the Anthropic. To use it, you need an Anthropic api key.
- As Anthropic is accepting large number of tokens, we have two options: for smaller prompts, use one prompt to get the information (quicker way!). To get the answer traditional
🏓 way (kudos to Tim for this proffessional term) the input must be large. For testing purposes locally, it is enough to change the if-clause in line 32 inJsonReader
class.
Current state of work (2023-05-31, 17:39 UTC)
- there are no specs
- I need to put the remarks from George in
- current implementation is compatible with the OpenAI. To move to Vertex, we need to change the response parsing
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- In the JsonReader class, uncomment one of the implementations in the
request
method - depending on which client you want to use. - In the rails console, define the context and the client
issue = Issue.find(612)
ai_request = Gitlab::Llm::Chain::Requests::Anthropic.new(User.first)
context = Gitlab::Llm::Chain::GitlabContext.new(current_user: User.first, container: issue.project.namespace, resource: issue, ai_request: ai_request)
- in the console call
q = Gitlab::Llm::Chain::Agents::ZeroShot::Executor.new(tools: [::Gitlab::Llm::Chain::Tools::IssueIdentifier, ::Gitlab::Llm::Chain::Tools::SummarizeComments, ::Gitlab::Llm::Chain::Tools::JsonReader], user_input: "What are the labels on issue #1?", context: context).execute
- Observe the returned value.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #412431
Edited by Alexandru Croitor