Replies: 1 comment
-
Hey @dzianisv! I'm here to help you with any questions or issues you have regarding the repository. If you need assistance, feel free to ask! To tune the
Here’s an example implementation: from langchain_core.pydantic_v1 import BaseModel, Field
from langchain.output_parsers import PydanticToolsParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
# Define the input argument model for the YouTube Search tool
class YouTubeSearchArgs(BaseModel):
query: str = Field(..., description="The search query for YouTube.")
max_results: int = Field(..., description="The maximum number of results to return.")
# Set up the prompt
system = """You are an expert at converting user questions into input arguments for the YouTube Search tool. \
You have access to a YouTube Search API. \
Generate the correct input arguments for the YouTube Search tool based on the user's question.
Return the arguments in the following format:
- query: The search query for YouTube.
- max_results: The maximum number of results to return."""
prompt = ChatPromptTemplate.from_messages(
[
("system", system),
("human", "{question}"),
]
)
# Initialize the LLM
llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)
llm_with_tools = llm.bind_tools([YouTubeSearchArgs])
query_analyzer = prompt | llm_with_tools | PydanticToolsParser(tools=[YouTubeSearchArgs])
# Example usage
response = query_analyzer.invoke(
{
"question": "Find the top 5 tutorials on LangChain"
}
)
print(response) This setup will help the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
I am trying to use Youtube Search agent with gpt-4o-mini, anyway I can tune the LLM or agent? The issue that 4o-mini ignores the specification of the input arguments.
{
"action": "youtube_search",
"action_input": {
"title": "Антонио Вивальди",
"description": "search for youtube videos associated with Antonio Vivaldi",
"type": "string"
}
}
Thank you in advance.
System Info
langchain==0.2.12
langchain-community==0.2.11
langchain-core==0.2.29
langchain-google-genai==1.0.8
langchain-openai==0.1.20
langchain-text-splitters==0.2.2
langchainhub==0.1.20
Beta Was this translation helpful? Give feedback.
All reactions