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

How can we make model response from its learning if no function calling is required #36

Open
sids07 opened this issue Sep 1, 2024 · 0 comments

Comments

@sids07
Copy link

sids07 commented Sep 1, 2024

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.

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

No branches or pull requests

1 participant