-
Notifications
You must be signed in to change notification settings - Fork 329
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
651fbfd
commit 1209cd8
Showing
13 changed files
with
501 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from pydantic import Field | ||
import ell | ||
|
||
ell.init(api_url='http://localhost:8081') | ||
|
||
@ell.tool() | ||
def get_weather(location: str = Field(description="The full name of a city and country, e.g. San Francisco, CA, USA")): | ||
"""Get the current weather for a given location.""" | ||
# Simulated weather API call | ||
return f"The weather in {location} is sunny." | ||
|
||
@ell.complex(model="gpt-4o", tools=[get_weather]) | ||
def travel_planner(destination: str): | ||
"""Plan a trip based on the destination and current weather.""" | ||
return [ | ||
ell.system("You are a travel planner. Use the weather tool to provide relevant advice."), | ||
ell.user(f"Plan a trip to {destination}") | ||
] | ||
|
||
result = travel_planner("Paris") | ||
print(result.text) # Prints travel advice | ||
if result.tool_calls: | ||
# This is done so that we can pass the tool calls to the language model | ||
tool_results = result.call_tools_and_collect_as_message() | ||
print("Weather info:", (tool_results.text)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.