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

Fix how Tools are stored. #111

Open
andreibondarev opened this issue Sep 23, 2024 · 2 comments
Open

Fix how Tools are stored. #111

andreibondarev opened this issue Sep 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@andreibondarev
Copy link
Collaborator

Currently when using the langchainrb_rails:assistant generator, we just store the class names of tools: https://github.com/patterns-ai-core/langchainrb_rails/blob/main/lib/langchainrb_overrides/assistant.rb#L27. This is problematic as tools are oftentimes instantiated with various environment variables. Should we store the initialization info as well?

@andreibondarev andreibondarev added the bug Something isn't working label Sep 23, 2024
@mattlindsey
Copy link

mattlindsey commented Nov 14, 2024

Seems like this will be a little complicated since you need to create an instance of each tool (e.g., MovieInfoTool.new(api_key: "...") here:

assistant = Langchain::Assistant.new(

For now you could just add code there to create any of the 8 'official' tools whose class names are stored and whose 'required environment variables' (in the README) are defined properly.

P.S.
Actually it looks like if you just fix the Google and Weather tools to have defaults in their initalize like NewsRetriever below, you should be all set just doing ToolName.new on each.

    def initialize(api_key: ENV["NEWS_API_KEY"])
      @api_key = api_key
    end

@emk-klaay
Copy link
Contributor

I created an ApplicationTool in my application, and all tools inherit from it. It has a unified initialization signature. This allows a strong convention for retrieving API keys and other information from the environment. This allows us to store the tools as an array ([langchain/tool/name, ...]) on the assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants