Skip to content

Commit

Permalink
Merge pull request #673 from kevinjyee/main
Browse files Browse the repository at this point in the history
Update function calling docs
  • Loading branch information
ishaan-jaff authored Oct 23, 2023
2 parents 0b7cc4b + 54cd10d commit e1b873a
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions docs/my-website/docs/completion/function_call.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,25 @@ messages = [
{"role": "user", "content": "What is the weather like in Boston?"}
]

def get_current_weather(location):
if location == "Boston, MA":
return "The weather is 12F"
def get_current_weather(location: str, unit: str):
"""Get the current weather in a given location
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)
print(response)
Expand All @@ -127,7 +141,7 @@ from litellm import completion
# 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

os.environ['OPENAI_API_KEY'] = ""
os.environ['ANTHROPIC_API_KEY'] = ""

messages = [
{"role": "user", "content": "What is the weather like in Boston?"}
Expand Down

0 comments on commit e1b873a

Please sign in to comment.