Skip to content
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

Create a Generator that would generate an Open API spec from a passed in Ruby class (Improve Tool creation for Assistants) #541

Open
andreibondarev opened this issue Mar 25, 2024 · 4 comments

Comments

@andreibondarev
Copy link
Collaborator

Description

We'd like to improve the experience of creating Tools (classes that inherit from Langchain::Tool::Base) for Assistants to use. Open API spec is difficult to compose and we'd like to see if an LLM itself can generate the JSON spec given a Ruby class.

Tasks

  • Create a .yaml prompt that instructs an LLM to generate a JSON Open API spec (example: database.json) and accepts a Ruby class.
  • Create a Generator class (under /utils? or maybe new directory /generators?) where this functionality will live.
  • This Generator class will output a .json file with the generator Open API spec.
@mattlindsey
Copy link
Contributor

mattlindsey commented Apr 24, 2024

Google added an enable_automatic_function_calling option to their python library that doesn't seem to requre a spec definition. Maybe do something like this:
https://github.com/google-gemini/cookbook/blob/main/examples/Agents_Function_Calling_Barista_Bot.ipynb

They say:

In the Python SDK you can pass functions directly to the model constructor, where the SDK will inspect the type signatures and docstrings to define the tools. For this reason it's important that you correctly type each of the parameters, give the functions sensible names and detailed docstrings.

@andreibondarev
Copy link
Collaborator Author

@mattlindsey Nice find! Unfortunately, unlike Python, Ruby does not have built-in type annotations.

@andreibondarev
Copy link
Collaborator Author

@mattlindsey I attached a branch where I'm working on an approach: generate-method-annotations

@mattlindsey
Copy link
Contributor

@andreibondarev Looks great. I can test it for you when ready. A further enhancement could be to make the annotation files optional by looking at the YARD annotations, or for tools that use RBS gem annotations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants