Skip to content

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)

  1. We could use more specs. @cablett did a fantastic job yesterday!
  2. I need to put the remarks from George in
  3. current implementation is compatible with the Anthropic. To use it, you need an Anthropic api key.
  4. 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 in JsonReader class.

Current state of work (2023-05-31, 17:39 UTC)

  1. there are no specs
  2. I need to put the remarks from George in
  3. 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.

  1. In the JsonReader class, uncomment one of the implementations in the request method - depending on which client you want to use.
  2. 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)
  1. 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
  1. 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.

Related to #412431

Edited by Alexandru Croitor

Merge request reports