tommy24 commited on
Commit
33cf851
·
1 Parent(s): 9d0a8b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -13
app.py CHANGED
@@ -953,24 +953,33 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
953
  # "model": model_llm
954
  # }).json()
955
 
 
 
 
 
 
 
 
 
 
956
  functions = [
957
  {
958
- "name": "getRandomInt",
959
- "description": "Returns a random integer between min (included) and max (included)",
960
  "parameters": {
961
  "type": "object",
962
  "properties": {
963
- "min": {
964
- "type": "number",
965
- "description": "Minimum value"
966
  },
967
- "max": {
968
- "type": "number",
969
- "description": "Maximum value"
970
  },
971
  },
972
- "required": ["min", "max"],
973
- }
974
  }
975
  ]
976
 
@@ -978,6 +987,7 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
978
  model="gpt-3.5-turbo",
979
  messages=messages,
980
  functions = functions,
 
981
  function_call = {
982
  "name": "getRandomInt"
983
  }
@@ -985,9 +995,12 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
985
 
986
 
987
  # reply = response["choices"][0]["message"]["content"]
988
- reply = completion.choices[0].message['content']
989
- print("RESPONSE TRY (NO IMAGE)", completion, reply)
990
-
 
 
 
991
  except:
992
  reply = "Maximum messages: 15. Please clear your history and Try Again! (No Image)"
993
  output.append({"Mode": "Chat", "content": reply})
 
953
  # "model": model_llm
954
  # }).json()
955
 
956
+ def add_decimal_values(arguments):
957
+ value1 = int(re.search(r'"value1": (\d+)', str(arguments)).group(1))
958
+ value2 = int(re.search(r'"value2": (\d+)', str(arguments)).group(1))
959
+
960
+ result = value1 + value2
961
+ print(f"{value1} + {value2} = {result} (decimal)")
962
+
963
+ return "Let's goooo", value1 + value2
964
+
965
  functions = [
966
  {
967
+ "name": "add_decimal_values",
968
+ "description": "Add two decimal values",
969
  "parameters": {
970
  "type": "object",
971
  "properties": {
972
+ "value1": {
973
+ "type": "integer",
974
+ "description": "The first decimal value to add. For example, 5",
975
  },
976
+ "value2": {
977
+ "type": "integer",
978
+ "description": "The second decimal value to add. For example, 10",
979
  },
980
  },
981
+ "required": ["value1", "value2"],
982
+ },
983
  }
984
  ]
985
 
 
987
  model="gpt-3.5-turbo",
988
  messages=messages,
989
  functions = functions,
990
+ function_choice = "auto",
991
  function_call = {
992
  "name": "getRandomInt"
993
  }
 
995
 
996
 
997
  # reply = response["choices"][0]["message"]["content"]
998
+ if completion.choices[0].finish_reason == "stop":
999
+ reply = completion.choices[0].message['content']
1000
+ print("RESPONSE TRY (NO IMAGE)", completion, reply)
1001
+ elif completion.choices[0].finish_reason == "function_call":
1002
+ reply = completion.choices[0].message['content']
1003
+ print("RESPONSE TRY (NO IMAGE) FUNCTION_CALL", completion, reply)
1004
  except:
1005
  reply = "Maximum messages: 15. Please clear your history and Try Again! (No Image)"
1006
  output.append({"Mode": "Chat", "content": reply})