added possibility for finding fractions
Browse files
app.py
CHANGED
@@ -3,20 +3,65 @@ import datetime
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
|
|
6 |
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 does nothing yet
|
15 |
-
Args:
|
16 |
-
arg1: the first argument
|
17 |
-
arg2: the second argument
|
18 |
"""
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
|
21 |
@tool
|
22 |
def get_current_time_in_timezone(timezone: str) -> str:
|
|
|
3 |
import requests
|
4 |
import pytz
|
5 |
import yaml
|
6 |
+
import tkapi
|
7 |
from tools.final_answer import FinalAnswerTool
|
8 |
|
9 |
from Gradio_UI import GradioUI
|
10 |
|
11 |
+
api = tkapi.TKApi()
|
12 |
+
|
13 |
+
|
14 |
@tool
|
15 |
+
def Get_Active_Fractions() -> List[Dict[str, str | int]]:
|
|
|
|
|
|
|
|
|
|
|
16 |
"""
|
17 |
+
Retrieves a list of all currently active fractions (political parties) in the Dutch parliament.
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
List[Dict[str, Union[str, int]]]: A list of dictionaries containing information about each fraction:
|
21 |
+
- 'naam': Full name of the political party (string)
|
22 |
+
- 'afkorting': Abbreviation/acronym of the party (string)
|
23 |
+
- 'zetels_aantal': Number of seats the party holds (integer)
|
24 |
+
|
25 |
+
Example return value:
|
26 |
+
[
|
27 |
+
{
|
28 |
+
'naam': 'Volkspartij voor Vrijheid en Democratie',
|
29 |
+
'afkorting': 'VVD',
|
30 |
+
'zetels_aantal': 34
|
31 |
+
},
|
32 |
+
{
|
33 |
+
'naam': 'Democraten 66',
|
34 |
+
'afkorting': 'D66',
|
35 |
+
'zetels_aantal': 24
|
36 |
+
}
|
37 |
+
]
|
38 |
+
"""
|
39 |
+
try:
|
40 |
+
# Initialize API client
|
41 |
+
api = tkapi.TKApi(verbose=False)
|
42 |
+
|
43 |
+
# Create filter for active fractions
|
44 |
+
filter = Fractie.create_filter()
|
45 |
+
filter.filter_actief()
|
46 |
+
|
47 |
+
# Get all active fractions
|
48 |
+
active_fractions = api.get_fracties(filter=filter)
|
49 |
+
|
50 |
+
# Format the results
|
51 |
+
results = []
|
52 |
+
for fraction in active_fractions:
|
53 |
+
fraction_info = {
|
54 |
+
'naam': fraction.naam,
|
55 |
+
'afkorting': fraction.afkorting,
|
56 |
+
'zetels_aantal': fraction.zetels_aantal
|
57 |
+
}
|
58 |
+
results.append(fraction_info)
|
59 |
+
|
60 |
+
return results
|
61 |
+
|
62 |
+
except Exception as e:
|
63 |
+
print(f"Error fetching fraction data: {str(e)}")
|
64 |
+
return []
|
65 |
|
66 |
@tool
|
67 |
def get_current_time_in_timezone(timezone: str) -> str:
|