gofannon 0.25.26__py3-none-any.whl → 0.25.27__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,119 @@
1
+ from ..base import BaseTool
2
+ from ..config import FunctionRegistry
3
+ import logging
4
+ import requests
5
+
6
+ logger = logging.getLogger(__name__)
7
+
8
+ @FunctionRegistry.register
9
+ class GrantsQueryTool(BaseTool):
10
+ """Query the EU Grants database for funding opportunities
11
+
12
+ Uses the EU Search API to find grant opportunities based on a search query.
13
+ Returns information about matching grants including title, identifier, deadline date and URL.
14
+ """
15
+ def __init__(self, name="grants_query"):
16
+ super().__init__
17
+ self.name = name
18
+
19
+ @property
20
+ def definition(self):
21
+ return {
22
+ "type": "function",
23
+ "function": {
24
+ "name": self.name,
25
+ "description": "Search for EU grant funding opportunities",
26
+ "parameters": {
27
+ "type": "object",
28
+ "properties": {
29
+ "query": {
30
+ "type": "string",
31
+ "description": "Search query to find relevant grant opportuities"
32
+ },
33
+ "page_size": {
34
+ "type": "integer",
35
+ "description": "Number of results to return (default: 5)",
36
+ "default": 5
37
+ },
38
+ "page_number": {
39
+ "type": "integer",
40
+ "description": "Page number for paginated results (default: 1)",
41
+ "default": 1
42
+ }
43
+ },
44
+ "requrired": ["query"]
45
+ }
46
+ }
47
+ }
48
+
49
+ def fn(self, query, page_size=5, page_number=1):
50
+ """Search for EU grants based on a query
51
+
52
+ Args:
53
+ query (str): Search term to find relevant grants
54
+ page_size (int): Number of results to return (default: 5)
55
+ page_number (int): Page number for paginated results (default: 1)
56
+
57
+ Returns:
58
+ dict: Dictionary containing sarch results and metadata
59
+
60
+ Raises:
61
+ ValueError: If the query is empty
62
+ requests.RequestException: If there is an error with the API request
63
+ """
64
+
65
+ try:
66
+ if not query:
67
+ raise ValueError("Query cannot be empty")
68
+
69
+ logger.debug(f"Searching for EU grants with query: {query}")
70
+
71
+ response = requests.post(
72
+ "https://api.tech.ec.europe.eu/search-api/prod/rest/search",
73
+ params={
74
+ "apiKey": "SEDIA",
75
+ "text": query,
76
+ "pageSize": page_size,
77
+ "pageNumber": page_number
78
+ },
79
+ json={
80
+ "languages": ["en"],
81
+ "displayFields": ["title", "identifier", "deadlineDate", "url"]
82
+ },
83
+ timeout=10
84
+ )
85
+ response.raise_for_status()
86
+
87
+ data = response.json()
88
+
89
+ formatted_results = []
90
+ for item in data.get("results", []):
91
+ title = item.get("content")
92
+ metadata = item.get("metadata", {})
93
+ deadline = metadata.get("deadlineDate")
94
+ identifier = metadata.get("identifier")
95
+ url = item.get("url")
96
+
97
+ formatted_results.append({
98
+ "title": title,
99
+ "identifier": identifier,
100
+ "deadline": deadline,
101
+ "url": url
102
+ })
103
+
104
+ result = {
105
+ "total_results": data.get("totalResults", 0),
106
+ "page": page_number,
107
+ "grants": formatted_results
108
+ }
109
+ return result
110
+
111
+ except ValueError as e:
112
+ logger.error(f"Value error in eu_grants_query: {str(e)}")
113
+ raise
114
+ except requests.exceptions.RequestException as e:
115
+ logger.error(f"API request failed in eu_grants_query: {str(e)}")
116
+ raise
117
+ except Exception as e:
118
+ logger.error(f"Unexpected error in eu_grants_query: {str(e)}")
119
+ raise
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gofannon
3
- Version: 0.25.26
3
+ Version: 0.25.27
4
4
  Summary: A collection of tools for LLMs
5
5
  License: ASFv2
6
6
  Author: Trevor Grant
@@ -35,6 +35,8 @@ gofannon/github/read_issue.py,sha256=JrnBAlZxknhHm3aLC0uB9u0bSvoQNfK3OKmxYlr8jgQ
35
35
  gofannon/github/search.py,sha256=yuX_dZ6f8ogUnskIRMUgF8wuN7JepqRtTDFrbmbwrrs,2183
36
36
  gofannon/google_search/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
37
  gofannon/google_search/google_search.py,sha256=WRaGSLoeZjy5Qtn89Sp01nNugiGI0NL1ZEdE1ebghl4,2100
38
+ gofannon/grant_query/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
+ gofannon/grant_query/grant_query.py,sha256=WuhCpHvAiUQQNUGt3XL4scMqSlc9nwlFGbGgwWwcX7k,4265
38
40
  gofannon/headless_browser/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
41
  gofannon/headless_browser/base.py,sha256=bgvBvkTNCqRnhC8Ffc6oZ3yoxpOl6fkAq0doDKnQtt8,1721
40
42
  gofannon/headless_browser/headless_browser_get.py,sha256=kOnHxfoZayfCuS6OKloLdwxehiInwcd5dM0HbKAeM5U,1182
@@ -69,7 +71,7 @@ gofannon/simpler_grants_gov/search_base.py,sha256=ask8ecAOQ9jZulr8iDxdfQZgSC_Eyx
69
71
  gofannon/simpler_grants_gov/search_opportunities.py,sha256=jZD64VqFIW36dBdAshOOQmywzLqBZyB3wLtA_C95sa8,19931
70
72
  gofannon/wikipedia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
71
73
  gofannon/wikipedia/wikipedia_lookup.py,sha256=J6wKPbSivCF7cccaiRaJW1o0VqNhQAGfrh5U1ULLesg,2869
72
- gofannon-0.25.26.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
73
- gofannon-0.25.26.dist-info/METADATA,sha256=UhHkuz-EgrXuxLamouS_-8C4hUOf8M3018C_bpx5Q-s,5509
74
- gofannon-0.25.26.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
75
- gofannon-0.25.26.dist-info/RECORD,,
74
+ gofannon-0.25.27.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
75
+ gofannon-0.25.27.dist-info/METADATA,sha256=jHU5mYq3dIjR0Sar34LFEpCrinIhYf8z2fXGEWcD8AI,5509
76
+ gofannon-0.25.27.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
77
+ gofannon-0.25.27.dist-info/RECORD,,