Merge pull request #673 from kevinjyee/main

Update function calling docs
This commit is contained in:
Ishaan Jaff 2023-10-23 10:42:34 -07:00 committed by GitHub
commit e1b873a2a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -103,11 +103,25 @@ messages = [
{"role": "user", "content": "What is the weather like in Boston?"} {"role": "user", "content": "What is the weather like in Boston?"}
] ]
def get_current_weather(location): def get_current_weather(location: str, unit: str):
if location == "Boston, MA": """Get the current weather in a given location
return "The weather is 12F"
functions = litellm.utils.function_to_dict(get_current_weather) Parameters
----------
location : str
The city and state, e.g. San Francisco, CA
unit : str {'celsius', 'fahrenheit'}
Temperature unit
Returns
-------
str
a sentence indicating the weather
"""
if location == "Boston, MA":
return "The weather is 12F"
functions = [litellm.utils.function_to_dict(get_current_weather)]
response = completion(model="gpt-3.5-turbo-0613", messages=messages, functions=functions) response = completion(model="gpt-3.5-turbo-0613", messages=messages, functions=functions)
print(response) print(response)
@ -127,7 +141,7 @@ from litellm import completion
# IMPORTANT - Set this to TRUE to add the function to the prompt for Non OpenAI LLMs # IMPORTANT - Set this to TRUE to add the function to the prompt for Non OpenAI LLMs
litellm.add_function_to_prompt = True # set add_function_to_prompt for Non OpenAI LLMs litellm.add_function_to_prompt = True # set add_function_to_prompt for Non OpenAI LLMs
os.environ['OPENAI_API_KEY'] = "" os.environ['ANTHROPIC_API_KEY'] = ""
messages = [ messages = [
{"role": "user", "content": "What is the weather like in Boston?"} {"role": "user", "content": "What is the weather like in Boston?"}