lawyer_assitance / functions /get_current_weather.py
qgyd2021's picture
[update]add function calling test
44e1a5b
raw
history blame
603 Bytes
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import json
def get_current_weather(location, unit="fahrenheit"):
if "tokyo" in location.lower():
return json.dumps({"location": location, "temperature": "10", "unit": "celsius"})
elif "san francisco" in location.lower():
return json.dumps({"location": location, "temperature": "72", "unit": "fahrenheit"})
else:
return json.dumps({"location": location, "temperature": "22", "unit": "celsius"})
def main():
result = get_current_weather("beijing")
print(result)
return
if __name__ == '__main__':
main()