Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -709,6 +709,8 @@ import os
|
|
| 709 |
import tensorflow as tf
|
| 710 |
import random
|
| 711 |
import openai
|
|
|
|
|
|
|
| 712 |
|
| 713 |
host = os.environ.get("host")
|
| 714 |
code = os.environ.get("code")
|
|
@@ -953,44 +955,58 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
| 953 |
# "model": model_llm
|
| 954 |
# }).json()
|
| 955 |
|
| 956 |
-
def get_current_weather(location, unit):
|
| 957 |
-
|
| 958 |
-
|
| 959 |
-
|
| 960 |
-
|
| 961 |
-
|
| 962 |
-
|
| 963 |
-
|
| 964 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 965 |
else:
|
| 966 |
-
return
|
| 967 |
-
|
| 968 |
-
functions = [
|
| 969 |
-
|
| 970 |
-
|
| 971 |
-
|
| 972 |
-
|
| 973 |
-
|
| 974 |
-
|
| 975 |
-
|
| 976 |
-
|
| 977 |
-
|
| 978 |
-
|
| 979 |
-
|
| 980 |
-
|
| 981 |
-
|
| 982 |
-
|
| 983 |
-
|
| 984 |
-
]
|
| 985 |
|
| 986 |
completion = openai.ChatCompletion.create(
|
| 987 |
model="gpt-3.5-turbo",
|
| 988 |
messages=messages,
|
| 989 |
-
functions =
|
| 990 |
-
|
| 991 |
-
function_call = {
|
| 992 |
-
"name": "get_current_weather"
|
| 993 |
-
}
|
| 994 |
)
|
| 995 |
|
| 996 |
reply = completion.choices[0].message['content']
|
|
|
|
| 709 |
import tensorflow as tf
|
| 710 |
import random
|
| 711 |
import openai
|
| 712 |
+
# from openai_decorator.openai_decorator import openaifunc, get_openai_funcs
|
| 713 |
+
from openai_decorator import openai_func, main
|
| 714 |
|
| 715 |
host = os.environ.get("host")
|
| 716 |
code = os.environ.get("code")
|
|
|
|
| 955 |
# "model": model_llm
|
| 956 |
# }).json()
|
| 957 |
|
| 958 |
+
# def get_current_weather(location, unit):
|
| 959 |
+
# params = {
|
| 960 |
+
# 'appid': '334f89b7998e8df818503b0f33085621',
|
| 961 |
+
# 'q': location,
|
| 962 |
+
# 'units': unit
|
| 963 |
+
# }
|
| 964 |
+
# response = requests.get('https://api.openweathermap.org/data/2.5/weather', params=params)
|
| 965 |
+
# if response.status_code == 200:
|
| 966 |
+
# return response.json()
|
| 967 |
+
# else:
|
| 968 |
+
# return None
|
| 969 |
+
|
| 970 |
+
@openaifunc
|
| 971 |
+
def testing_this(name: str, number: str) -> str:
|
| 972 |
+
"""
|
| 973 |
+
This function ask user for their name and a random integer and returns it.
|
| 974 |
+
@param name: The name of the user
|
| 975 |
+
@param number: Random number entered by the user
|
| 976 |
+
"""
|
| 977 |
+
|
| 978 |
+
if name is None:
|
| 979 |
+
return "Your name must be provided, inorder to run the function call"
|
| 980 |
+
elif number is None:
|
| 981 |
+
return "A random number must be provided, inorder to run the function call"
|
| 982 |
+
elif name is None and number is None :
|
| 983 |
+
return "You must provide your name and a random number to continue."
|
| 984 |
else:
|
| 985 |
+
return "Function call successfull", name, str(int)
|
| 986 |
+
|
| 987 |
+
# functions = [
|
| 988 |
+
# {
|
| 989 |
+
# "name": "get_current_weather",
|
| 990 |
+
# "description": "Get the current weather in a given location",
|
| 991 |
+
# "parameters": {
|
| 992 |
+
# "type": "object",
|
| 993 |
+
# "properties": {
|
| 994 |
+
# "location": {
|
| 995 |
+
# "type": "string",
|
| 996 |
+
# "description": "The city and state, e.g. San Francisco, CA",
|
| 997 |
+
# },
|
| 998 |
+
# "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
|
| 999 |
+
# },
|
| 1000 |
+
# "required": ["location"],
|
| 1001 |
+
# },
|
| 1002 |
+
# }
|
| 1003 |
+
# ]
|
| 1004 |
|
| 1005 |
completion = openai.ChatCompletion.create(
|
| 1006 |
model="gpt-3.5-turbo",
|
| 1007 |
messages=messages,
|
| 1008 |
+
functions = get_openai_funcs(),
|
| 1009 |
+
function_call = "auto",
|
|
|
|
|
|
|
|
|
|
| 1010 |
)
|
| 1011 |
|
| 1012 |
reply = completion.choices[0].message['content']
|