Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,16 +7,75 @@ from tools.final_answer import FinalAnswerTool
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
-
#
|
11 |
@tool
|
12 |
-
def
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
-
"""A tool that
|
15 |
Args:
|
16 |
-
|
17 |
-
|
|
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
@@ -55,7 +114,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
55 |
|
56 |
agent = CodeAgent(
|
57 |
model=model,
|
58 |
-
tools=[
|
59 |
max_steps=6,
|
60 |
verbosity_level=1,
|
61 |
grammar=None,
|
|
|
7 |
|
8 |
from Gradio_UI import GradioUI
|
9 |
|
10 |
+
# Fetch mello roos taxes for addresses in Sacramento County
|
11 |
@tool
|
12 |
+
def sacramento_county_mello_roos_tool(street_number:str, street_name:str, city:str)-> str: #it's import to specify the return type
|
13 |
#Keep this format for the description / args / args description but feel free to modify the tool
|
14 |
+
"""A tool that fetches the tax data for addresses in the Sacramento county and returns the levy portions of the property taxes including the Mello Roos taxes
|
15 |
Args:
|
16 |
+
street_number: Street number of the address
|
17 |
+
street_name: Street name of the address
|
18 |
+
city: City of the address
|
19 |
"""
|
20 |
+
parcel_api_url = "https://services1.arcgis.com/5NARefyPVtAeuJPU/arcgis/rest/services/Parcels/FeatureServer/0/query"
|
21 |
+
where_clause = f"STREET_NBR='{street_number}' AND STREET_NAM='{street_name}' AND CITY='{city}'"
|
22 |
+
params = {
|
23 |
+
'where': where_clause,
|
24 |
+
'outFields': '*',
|
25 |
+
'f': 'json'
|
26 |
+
}
|
27 |
+
|
28 |
+
# Fetch parcel data
|
29 |
+
parcel_response = requests.get(parcel_api_url, params=params)
|
30 |
+
if parcel_response.status_code != 200:
|
31 |
+
return jsonify({"error": f"Parcel API request failed with status code {parcel_response.status_code}, response: {parcel_response.text}"}), 400
|
32 |
+
|
33 |
+
parcel_data = parcel_response.json()
|
34 |
+
|
35 |
+
# Ensure parcel data is valid
|
36 |
+
if 'features' not in parcel_data or len(parcel_data['features']) == 0:
|
37 |
+
return jsonify({"error": "No parcel data found"}), 400
|
38 |
+
|
39 |
+
parcel_number = parcel_data['features'][0]['attributes'].get('APN')
|
40 |
+
if not parcel_number:
|
41 |
+
return jsonify({"error": "Parcel number not found"}), 400
|
42 |
+
|
43 |
+
# Fetch bill details using the parcel number
|
44 |
+
bill_summary_url = f"https://eproptax.saccounty.net/servicev2/eproptax.svc/rest/BillSummary?parcel={parcel_number}"
|
45 |
+
bill_response = requests.get(bill_summary_url)
|
46 |
+
if bill_response.status_code != 200:
|
47 |
+
return jsonify({"error": f"Bill API request failed with status code {bill_response.status_code}, response: {bill_response.text}"}), 400
|
48 |
+
|
49 |
+
bill_data = bill_response.json()
|
50 |
+
|
51 |
+
# Ensure bill data is valid
|
52 |
+
if not bill_data.get('Success'):
|
53 |
+
return jsonify({"error": "Failed to retrieve bill data"}), 400
|
54 |
+
|
55 |
+
# Get the bill number and roll date
|
56 |
+
bill_number = bill_data['Bills'][0]['BillNumber']
|
57 |
+
roll_date = bill_data['Bills'][0]['RollDate']
|
58 |
+
|
59 |
+
# Fetch levy details using the bill number and current year
|
60 |
+
levy_url = f"https://eproptax.saccounty.net/servicev2/eproptax.svc/rest/DirectLevy?rollYear={roll_date}&billNumber={bill_number}"
|
61 |
+
levy_response = requests.get(levy_url)
|
62 |
+
if levy_response.status_code != 200:
|
63 |
+
return jsonify({"error": f"Levy API request failed with status code {levy_response.status_code}, response: {levy_response.text}"}), 400
|
64 |
+
|
65 |
+
levy_data = levy_response.json()
|
66 |
+
|
67 |
+
# Ensure levy data is valid
|
68 |
+
if not levy_data.get('Success'):
|
69 |
+
return jsonify({"error": "Failed to retrieve levy data"}), 400
|
70 |
+
|
71 |
+
# Prepare the response
|
72 |
+
response_data = {
|
73 |
+
"total_amount": levy_data['BillAmount'],
|
74 |
+
"levy_total": levy_data['LevyTotal'],
|
75 |
+
"levies": levy_data['Levies']
|
76 |
+
}
|
77 |
+
|
78 |
+
return jsonify(response_data)
|
79 |
|
80 |
@tool
|
81 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
114 |
|
115 |
agent = CodeAgent(
|
116 |
model=model,
|
117 |
+
tools=[sacramento_county_mello_roos_tool, image_generation_tool, final_answer], ## add your tools here (don't remove final answer)
|
118 |
max_steps=6,
|
119 |
verbosity_level=1,
|
120 |
grammar=None,
|