Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1029,23 +1029,52 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
| 1029 |
comp = completion.choices[0].message
|
| 1030 |
print("\nCOMPPP MESSAGE:", comp)
|
| 1031 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1032 |
if comp.get("function_call"):
|
| 1033 |
function_name = comp["function_call"]["name"]
|
| 1034 |
-
|
| 1035 |
# Convert JSON string to Python dictionary
|
| 1036 |
-
|
| 1037 |
-
|
| 1038 |
-
# Extract values
|
| 1039 |
-
function_call = data["function_call"]
|
| 1040 |
-
arguments_str = function_call["arguments"]
|
| 1041 |
arguments_dict = json.loads(arguments_str)
|
| 1042 |
-
|
| 1043 |
function_response = testing_this(
|
| 1044 |
name=arguments_dict["name"],
|
| 1045 |
number=arguments_dict["number"]
|
| 1046 |
)
|
| 1047 |
print("FUNCTION_RESPONSE:", function_response)
|
| 1048 |
-
print("ARGUMENTS VALUES:", arguments_dict["
|
| 1049 |
messages.append(comp)
|
| 1050 |
messages.append({
|
| 1051 |
"role": "function",
|
|
|
|
| 1029 |
comp = completion.choices[0].message
|
| 1030 |
print("\nCOMPPP MESSAGE:", comp)
|
| 1031 |
|
| 1032 |
+
# if comp.get("function_call"):
|
| 1033 |
+
# function_name = comp["function_call"]["name"]
|
| 1034 |
+
|
| 1035 |
+
# # Convert JSON string to Python dictionary
|
| 1036 |
+
# data = json.loads(comp)
|
| 1037 |
+
|
| 1038 |
+
# # Extract values
|
| 1039 |
+
# function_call = data["function_call"]
|
| 1040 |
+
# arguments_str = function_call["arguments"]
|
| 1041 |
+
# arguments_dict = json.loads(arguments_str)
|
| 1042 |
+
|
| 1043 |
+
# function_response = testing_this(
|
| 1044 |
+
# name=arguments_dict["name"],
|
| 1045 |
+
# number=arguments_dict["number"]
|
| 1046 |
+
# )
|
| 1047 |
+
# print("FUNCTION_RESPONSE:", function_response)
|
| 1048 |
+
# print("ARGUMENTS VALUES:", arguments_dict["number"], arguments_dict["number"])
|
| 1049 |
+
# messages.append(comp)
|
| 1050 |
+
# messages.append({
|
| 1051 |
+
# "role": "function",
|
| 1052 |
+
# "name": function_name,
|
| 1053 |
+
# "content": function_response
|
| 1054 |
+
# })
|
| 1055 |
+
# second_response = openai.ChatCompletion.create(
|
| 1056 |
+
# model="gpt-3.5-turbo",
|
| 1057 |
+
# messages=messages
|
| 1058 |
+
# )
|
| 1059 |
+
# print("YES_FUNCTION_CALL RESPONSE TRY (NO IMAGE)")
|
| 1060 |
+
# return second_response
|
| 1061 |
+
# else:
|
| 1062 |
+
# reply = comp['content']
|
| 1063 |
+
# print("RESPONSE TRY (NO IMAGE, FUNCTION_CALL)")
|
| 1064 |
+
|
| 1065 |
if comp.get("function_call"):
|
| 1066 |
function_name = comp["function_call"]["name"]
|
| 1067 |
+
|
| 1068 |
# Convert JSON string to Python dictionary
|
| 1069 |
+
arguments_str = comp["function_call"]["arguments"]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1070 |
arguments_dict = json.loads(arguments_str)
|
| 1071 |
+
|
| 1072 |
function_response = testing_this(
|
| 1073 |
name=arguments_dict["name"],
|
| 1074 |
number=arguments_dict["number"]
|
| 1075 |
)
|
| 1076 |
print("FUNCTION_RESPONSE:", function_response)
|
| 1077 |
+
print("ARGUMENTS VALUES:", arguments_dict["name"], arguments_dict["number"])
|
| 1078 |
messages.append(comp)
|
| 1079 |
messages.append({
|
| 1080 |
"role": "function",
|