-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
2 changed files
with
66 additions
and
9 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,32 @@ | ||
import logging | ||
from prompete import Chat | ||
from pprint import pprint | ||
|
||
# Configure logging | ||
logging.basicConfig( | ||
level=logging.DEBUG, | ||
format='%(asctime)s - %(levelname)s - %(message)s' | ||
) | ||
|
||
def get_current_weather(location: str, unit: str = "celsius") -> str: | ||
"""Get the current weather in a given location""" | ||
# In a real scenario, you would call an actual weather API here | ||
return { | ||
"location": location, | ||
"temperature": 22, | ||
"unit": unit, | ||
"forecast": ["sunny", "windy"], | ||
} | ||
|
||
# Create a Chat instance | ||
chat = Chat(model="gpt-4o-mini") | ||
|
||
# Define the user's question | ||
user_question = "Please check the weather in London (using the `get_current_weather` function) and suggest an appropriate outfit." | ||
answer = chat.tool_loop(user_question, max_loops = 3, tools=[get_current_weather]) | ||
|
||
# Print the results | ||
print("User: ", user_question) | ||
print("Answer: ", answer) | ||
|
||
pprint(chat.messages) |
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