Skip to content

Commit

Permalink
enh: better fc example
Browse files Browse the repository at this point in the history
  • Loading branch information
tjbck committed Jun 1, 2024
1 parent 828ad33 commit 6b42931
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions examples/function_calling_filter_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ def get_current_weather(
print(location, unit)
return f"{location}: Sunny"

def get_user_name(self, user_id: str) -> str:
def calculator(self, equation: str) -> str:
"""
Get the user's name from the user_id.
Calculate the result of an equation.
:param equation: The equation to calculate.
"""
print(user_id)
return "John Doe"

# Avoid using eval in production code
# https://nedbatchelder.com/blog/201206/eval_really_is_dangerous.html
try:
result = eval(equation)
return f"{equation} = {result}"
except Exception as e:
print(e)
return "Invalid equation"

self.functions = Functions()

Expand Down

0 comments on commit 6b42931

Please sign in to comment.