You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was playing around with the repo and found prompt has been set such that it will always do some function calling. But what I require is the only function calling if required, or else a response as a normal text generation model to generate a response from its learning.
With the default prompt, it gives a response by making up another function call that is not present in the function signature.
My code for tools is:
from langchain.tools import tool
from langchain_core.utils.function_calling import convert_to_openai_tool
from typing import List
@tool
def get_current_weather(location: str) -> str:
"""
Get the current weather information of any given location.
Args:
location (str): location of the place we want to know the current weather of.
Returns:
str: current weather of the location
"""
if location == "San Francisco, CA":
return "62 degrees and cloudy"
elif location == "Philadelphia, PA":
return "83 degrees and sunny"
return "Weather is unknown"
def initialize_tools(function_list: List[str]) -> List[dict]:
return [convert_to_openai_tool(f) for f in function_list]
tools = initialize_tools([get_current_weather])
Now when the user sends something like "Who is the prime minister of Nepal?", it will respond as {"name": "get_country_leader", "arguments": {"country_code": "NP"}},
NOTE: I haven't passed any get_country_leader function as a tool.
Here, I was expecting the model to reply to who is the prime minister of Nepal from its training data since no function call was required.
Any suggestions or references on how this scenario can be achieved would be really crucial. Also, I was trying to tweak the prompts to do so, but the result was not good. Thank you.
The text was updated successfully, but these errors were encountered:
I was playing around with the repo and found prompt has been set such that it will always do some function calling. But what I require is the only function calling if required, or else a response as a normal text generation model to generate a response from its learning.
With the default prompt, it gives a response by making up another function call that is not present in the function signature.
My code for tools is:
Now when the user sends something like "Who is the prime minister of Nepal?", it will respond as {"name": "get_country_leader", "arguments": {"country_code": "NP"}},
NOTE: I haven't passed any get_country_leader function as a tool.
Here, I was expecting the model to reply to who is the prime minister of Nepal from its training data since no function call was required.
Any suggestions or references on how this scenario can be achieved would be really crucial. Also, I was trying to tweak the prompts to do so, but the result was not good. Thank you.
The text was updated successfully, but these errors were encountered: