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

added support for tools on VertexAI #14839

Closed
wants to merge 2 commits into from

Conversation

lkuligin
Copy link
Collaborator

  • Description: added support for tools on VertexAI
  • Twitter handle: lkuligin

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Dec 18, 2023
Copy link

vercel bot commented Dec 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Dec 18, 2023 4:46pm

@dosubot dosubot bot added Ɑ: models Related to LLMs or chat model modules 🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features labels Dec 18, 2023
def format_tool_to_vertex_function(tool: Tool) -> FunctionDescription:
"Format tool into the Vertex function API."
if tool.args_schema:
return convert_pydantic_to_openai_function(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i tried this out and it errors, i think you need to remove title from the json schema that is generated

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hwchase17 which error do you get?

I've just tried this again

raw_tools = [
    Tool(
        name="Search",
        func=search.run,
        description="useful for when you need to answer questions about current events. You should ask targeted questions",
    ),
    Tool(
        name="Calculator",
        func=llm_math_chain.run,
        description="useful for when you need to answer questions about math",
    )
]
tools = [format_tool_to_vertex_tool(tool) for tool in raw_tools]

and it seems to be working fine.

and there's also a working integration test:

@@ -14,7 +15,48 @@
from langchain.agents.agent import AgentOutputParser


class OpenAIFunctionsAgentOutputParser(AgentOutputParser):
class BaseFunctionsAgentOutputParser(AgentOutputParser):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like creating a BaseFunctionsAgentOutputParser that both of these fit into, but I think this class and the VertexAIFunctionsAgentOutputParser should be in a separate file outside of the OpenAI parser

@efriis
Copy link
Member

efriis commented Jan 16, 2024

Adding to vertex partner package in #15822

@efriis efriis closed this Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:enhancement A large net-new component, integration, or chain. Use sparingly. The largest features Ɑ: models Related to LLMs or chat model modules size:L This PR changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants