mar480 commited on
Commit
cbf2011
·
verified ·
1 Parent(s): 6e83e93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -8
app.py CHANGED
@@ -8,16 +8,39 @@ from tools.final_answer import FinalAnswerTool
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
- # @tool
12
- # def stockticker(companyName: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 searches the web for the stock market ticker code for a given company name
15
- # Args:
16
- # companyName: name of the company
17
- # """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
 
20
- # return "What magic will you build ?"
21
 
22
  # searchtool = DuckDuckGoSearchTool()
23
 
 
8
  from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
+ @tool
12
+ def chChecker(companyNumber:str, year:int)-> 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 checks whether the last accounts filing at Companies House for a specific company used XBRL
15
+ Args:
16
+ companyNumber: Company Registration Number (CRN)
17
+ """
18
+
19
+ chapi = r"12fc98d5-f42a-4c63-8db0-d68a9050ef9e"
20
+ url = f"https://api.company-information.service.gov.uk/company/{companyNumber}/filing-history"
21
+ params = {'category': 'accounts'}
22
+
23
+ response = requests.get(url, params=params, auth=(chapi, ''))
24
+
25
+ if response and response.status_code == 200:
26
+ company_data = response.json()
27
+
28
+ for filing in company_data["items"]:
29
+ document_metadata_url = filing.get("links", {}).get("document_metadata")
30
+ dmresponse = requests.get(document_metadata_url, params=params, auth=(chapi, ''))
31
+ if dmresponse and dmresponse.status_code == 200:
32
+ filing_data = dmresponse.json()
33
+ xbrl = False
34
+
35
+ if 'application/xhtml+xml' in filing_data.get('resources', {}):
36
+ xbrl = True
37
+
38
+ return xbrl
39
+
40
+
41
 
42
 
43
+
44
 
45
  # searchtool = DuckDuckGoSearchTool()
46