Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -966,21 +966,21 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
966 |
# return None
|
967 |
|
968 |
# @openai_func
|
969 |
-
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
|
985 |
# functions = [
|
986 |
# {
|
@@ -1024,9 +1024,34 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
1024 |
functions = functions,
|
1025 |
function_call = "auto",
|
1026 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1027 |
|
1028 |
-
reply =
|
1029 |
-
print("RESPONSE TRY (NO IMAGE)", completion, reply)
|
1030 |
except Exception as e:
|
1031 |
print("Error",e)
|
1032 |
reply = "Maximum messages: 15. Please clear your history and Try Again! (No Image)"
|
|
|
966 |
# return None
|
967 |
|
968 |
# @openai_func
|
969 |
+
def testing_this(name: str, number: str) -> str:
|
970 |
+
"""
|
971 |
+
This function ask user for their name and a random integer and returns it.
|
972 |
+
@param name: The name of the user
|
973 |
+
@param number: Random number entered by the user
|
974 |
+
"""
|
975 |
+
|
976 |
+
if name is None:
|
977 |
+
return "Your name must be provided, inorder to run the function call"
|
978 |
+
elif number is None:
|
979 |
+
return "A random number must be provided, inorder to run the function call"
|
980 |
+
elif name is None and number is None :
|
981 |
+
return "You must provide your name and a random number to continue."
|
982 |
+
else:
|
983 |
+
return "Function call successfull", name, str(int)
|
984 |
|
985 |
# functions = [
|
986 |
# {
|
|
|
1024 |
functions = functions,
|
1025 |
function_call = "auto",
|
1026 |
)
|
1027 |
+
|
1028 |
+
comp = completion.choices[0].message
|
1029 |
+
|
1030 |
+
if comp.get("function_call"):
|
1031 |
+
function_name = comp["function_call"]["name"]
|
1032 |
+
|
1033 |
+
function_response = testing_this(
|
1034 |
+
name= comp.get("name"),
|
1035 |
+
number = comp.get("number")
|
1036 |
+
)
|
1037 |
+
messages.append(comp)
|
1038 |
+
messages.append({
|
1039 |
+
"role": "function",
|
1040 |
+
"name": function_name,
|
1041 |
+
"content": function_response
|
1042 |
+
})
|
1043 |
+
second_response = openai.ChatCompletion.create(
|
1044 |
+
model="gpt-3.5-turbo",
|
1045 |
+
messages=
|
1046 |
+
)
|
1047 |
+
print("YES_FUNCTION_CALL RESPONSE TRY (NO IMAGE)")
|
1048 |
+
return second_response
|
1049 |
+
else:
|
1050 |
+
reply = comp['content']
|
1051 |
+
print("RESPONSE TRY (NO IMAGE, FUNCTION_CALL)")
|
1052 |
|
1053 |
+
# reply = comp['content']
|
1054 |
+
# print("RESPONSE TRY (NO IMAGE)", completion, reply)
|
1055 |
except Exception as e:
|
1056 |
print("Error",e)
|
1057 |
reply = "Maximum messages: 15. Please clear your history and Try Again! (No Image)"
|