Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -983,52 +983,112 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
| 983 |
# else:
|
| 984 |
# return "Function call successfull"
|
| 985 |
|
| 986 |
-
def
|
|
|
|
| 987 |
"""
|
| 988 |
-
This function
|
| 989 |
-
@param
|
| 990 |
-
@param
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 991 |
"""
|
| 992 |
-
|
| 993 |
-
if
|
| 994 |
-
return "
|
| 995 |
else:
|
| 996 |
-
|
| 997 |
-
|
| 998 |
-
|
| 999 |
-
|
| 1000 |
-
|
| 1001 |
-
|
| 1002 |
-
|
| 1003 |
-
|
| 1004 |
-
|
| 1005 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1006 |
|
| 1007 |
-
|
| 1008 |
-
|
| 1009 |
-
|
| 1010 |
-
|
| 1011 |
-
|
| 1012 |
-
|
| 1013 |
|
| 1014 |
-
|
| 1015 |
-
|
| 1016 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1017 |
|
| 1018 |
functions = [
|
| 1019 |
{
|
| 1020 |
-
"name": "
|
| 1021 |
-
"description": "
|
| 1022 |
"parameters": {
|
| 1023 |
"type": "object",
|
| 1024 |
"properties": {
|
| 1025 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1026 |
"type": "string",
|
| 1027 |
-
"description": "The
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1028 |
},
|
| 1029 |
-
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
|
| 1030 |
},
|
| 1031 |
-
"required": ["
|
| 1032 |
},
|
| 1033 |
}
|
| 1034 |
]
|
|
@@ -1101,13 +1161,20 @@ def classify(platform, UserInput, Images, Textbox2, Textbox3):
|
|
| 1101 |
arguments_str = comp["function_call"]["arguments"]
|
| 1102 |
arguments_dict = json.loads(arguments_str)
|
| 1103 |
|
| 1104 |
-
function_response =
|
| 1105 |
-
|
| 1106 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1107 |
)
|
| 1108 |
|
| 1109 |
print("FUNCTION_RESPONSE:", function_response)
|
| 1110 |
-
print("ARGUMENTS VALUES:", arguments_dict["location"], arguments_dict["unit"])
|
|
|
|
|
|
|
| 1111 |
# messages.append(comp)
|
| 1112 |
# messages.append({
|
| 1113 |
# "role": "function",
|
|
|
|
| 983 |
# else:
|
| 984 |
# return "Function call successfull"
|
| 985 |
|
| 986 |
+
def book_enquiry(name: str, contact_number: str, street_address: str,
|
| 987 |
+
landmark: str, zip_code: str, emirate: str, reason: str):
|
| 988 |
"""
|
| 989 |
+
This function asks the user for their details and books an enquiry for waste disposal.
|
| 990 |
+
@param name: The name of the user
|
| 991 |
+
@param contact_number: The contact number of the user
|
| 992 |
+
@param street_address: The street address of the user
|
| 993 |
+
@param landmark: The landmark near the user's location
|
| 994 |
+
@param zip_code: The zip code of the user's location
|
| 995 |
+
@param emirate: The emirate of the user's location
|
| 996 |
+
@param reason: The reason for waste disposal enquiry
|
| 997 |
"""
|
| 998 |
+
|
| 999 |
+
if not all([name, contact_number, street_address, landmark, zip_code, emirate, reason]):
|
| 1000 |
+
return "You must provide your details to book an enquiry."
|
| 1001 |
else:
|
| 1002 |
+
print(f"Booking enquiry for {name} with contact number {contact_number}.")
|
| 1003 |
+
return f"Booking enquiry for {name} with contact number {contact_number} successful."
|
| 1004 |
+
|
| 1005 |
+
# def get_current_weather(location: str, unit: str):
|
| 1006 |
+
# """
|
| 1007 |
+
# This function get's the current weather in a given location.
|
| 1008 |
+
# @param location: The name of the user
|
| 1009 |
+
# @param unit: Random number entered by the user
|
| 1010 |
+
# """
|
| 1011 |
+
|
| 1012 |
+
# if location is None:
|
| 1013 |
+
# return "Your name must be provided, inorder to run the function call"
|
| 1014 |
+
# else:
|
| 1015 |
+
# params = {
|
| 1016 |
+
# 'appid': '334f89b7998e8df818503b0f33085621',
|
| 1017 |
+
# 'q': location,
|
| 1018 |
+
# 'units': unit
|
| 1019 |
+
# }
|
| 1020 |
+
# response = requests.get('https://api.openweathermap.org/data/2.5/weather', params=params)
|
| 1021 |
+
# print(response.status_code)
|
| 1022 |
+
# if response.status_code == 200:
|
| 1023 |
+
# temperature = weather_data.get('main', {}).get('temp', 'TEMP_FROM_THE_JSON')
|
| 1024 |
+
# forecast = [item.get('description', '') for item in weather_data.get('weather', [])]
|
| 1025 |
|
| 1026 |
+
# new_json = {
|
| 1027 |
+
# "location": location,
|
| 1028 |
+
# "temperature": temperature,
|
| 1029 |
+
# "unit": unit,
|
| 1030 |
+
# "forecast": forecast
|
| 1031 |
+
# }
|
| 1032 |
|
| 1033 |
+
# return new_json
|
| 1034 |
+
# else:
|
| 1035 |
+
# return None
|
| 1036 |
+
|
| 1037 |
+
# functions = [
|
| 1038 |
+
# {
|
| 1039 |
+
# "name": "get_current_weather",
|
| 1040 |
+
# "description": "Get the current weather in a given location",
|
| 1041 |
+
# "parameters": {
|
| 1042 |
+
# "type": "object",
|
| 1043 |
+
# "properties": {
|
| 1044 |
+
# "location": {
|
| 1045 |
+
# "type": "string",
|
| 1046 |
+
# "description": "The city and state, e.g. San Francisco, CA",
|
| 1047 |
+
# },
|
| 1048 |
+
# "unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
|
| 1049 |
+
# },
|
| 1050 |
+
# "required": ["location"],
|
| 1051 |
+
# },
|
| 1052 |
+
# }
|
| 1053 |
+
# ]
|
| 1054 |
|
| 1055 |
functions = [
|
| 1056 |
{
|
| 1057 |
+
"name": "book_enquiry",
|
| 1058 |
+
"description": "Book an equiry with the user provided details to the support team",
|
| 1059 |
"parameters": {
|
| 1060 |
"type": "object",
|
| 1061 |
"properties": {
|
| 1062 |
+
"name": {
|
| 1063 |
+
"type": "string",
|
| 1064 |
+
"description": "The name of the user, e.g. Alex, David",
|
| 1065 |
+
},
|
| 1066 |
+
"contact_number": {
|
| 1067 |
+
"type": "string",
|
| 1068 |
+
"description": "The contact number of the user, e.g. 1234567890",
|
| 1069 |
+
},
|
| 1070 |
+
"street_address": {
|
| 1071 |
"type": "string",
|
| 1072 |
+
"description": "The street address of the user, e.g. Omando Street 123",
|
| 1073 |
+
},
|
| 1074 |
+
"landmark": {
|
| 1075 |
+
"type": "string",
|
| 1076 |
+
"description": "The landmark of the user near his location, e.g. Near 123 Hotel",
|
| 1077 |
+
},
|
| 1078 |
+
"zip_code": {
|
| 1079 |
+
"type": "string",
|
| 1080 |
+
"description": "The zipcode of the user's location, e.g. 367774, 0000",
|
| 1081 |
+
},
|
| 1082 |
+
"emirate": {
|
| 1083 |
+
"type": "string",
|
| 1084 |
+
"description": "The emirate of the user's location, e.g. Sharjah, Abudhabi",
|
| 1085 |
+
},
|
| 1086 |
+
"reason": {
|
| 1087 |
+
"type": "string",
|
| 1088 |
+
"description": "The reason for the user's enquiry",
|
| 1089 |
},
|
|
|
|
| 1090 |
},
|
| 1091 |
+
"required": ["name", "contact_number", "street_address", "landmark", "zip_code", "emirate", "reason"],
|
| 1092 |
},
|
| 1093 |
}
|
| 1094 |
]
|
|
|
|
| 1161 |
arguments_str = comp["function_call"]["arguments"]
|
| 1162 |
arguments_dict = json.loads(arguments_str)
|
| 1163 |
|
| 1164 |
+
function_response = book_enquiry(
|
| 1165 |
+
name=arguments_dict["name"],
|
| 1166 |
+
contact_number=arguments_dict["contact_number"],
|
| 1167 |
+
street_address=arguments_dict["street_address"],
|
| 1168 |
+
landmark=arguments_dict["landmark"],
|
| 1169 |
+
zip_code=arguments_dict["zip_code"],
|
| 1170 |
+
emirate=arguments_dict["emirate"],
|
| 1171 |
+
reason=arguments_dict["reason"]
|
| 1172 |
)
|
| 1173 |
|
| 1174 |
print("FUNCTION_RESPONSE:", function_response)
|
| 1175 |
+
# print("ARGUMENTS VALUES:", arguments_dict["location"], arguments_dict["unit"])
|
| 1176 |
+
print(f"ARGUMENTS VALUES: Name: {arguments_dict['name']}, Contact Number: {arguments_dict['contact_number']}, Street Address: {arguments_dict['street_address']}, Landmark: {arguments_dict['landmark']}, Zip Code: {arguments_dict['zip_code']}, Emirate: {arguments_dict['emirate']}, Reason: {arguments_dict['reason']}")
|
| 1177 |
+
|
| 1178 |
# messages.append(comp)
|
| 1179 |
# messages.append({
|
| 1180 |
# "role": "function",
|