gofannon 0.25.21__py3-none-any.whl → 0.25.23__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.
@@ -3,6 +3,7 @@
3
3
  import inspect
4
4
  import json
5
5
  from typing import Any, Callable, Dict, List, Optional, Type as TypingType
6
+ import functools # Add this import
6
7
 
7
8
  # Try to import ADK components
8
9
  try:
@@ -51,7 +52,7 @@ except ImportError:
51
52
  self.parameters = parameters
52
53
 
53
54
 
54
- # Helper for ADK Schema to Gofannon JSON Schema
55
+ # Helper for ADK Schema to Gofannon JSON Schema
55
56
  ADK_GEMINI_TYPE_TO_JSON_TYPE = {
56
57
  adk_gemini_types.Type.STRING: "string",
57
58
  adk_gemini_types.Type.INTEGER: "integer",
@@ -279,7 +280,9 @@ class AdkMixin:
279
280
  else:
280
281
  # Gofannon's synchronous fn needs to be run in a thread
281
282
  # as ADK's run_async is an async method.
282
- return await anyio.to_thread.run_sync(self._gofannon_exec_fn, **args) # type: ignore
283
+ # Use functools.partial to create a callable with arguments pre-bound.
284
+ func_with_bound_args = functools.partial(self._gofannon_exec_fn, **args)
285
+ return await anyio.to_thread.run_sync(func_with_bound_args)
283
286
 
284
287
  exported_adk_tool = GofannonAdkTool(
285
288
  name=tool_name,
File without changes
@@ -0,0 +1,70 @@
1
+ from ..base import BaseTool
2
+ from ..config import FunctionRegistry, ToolConfig
3
+ import requests
4
+ import logging
5
+
6
+ logger = logging.getLogger(__name__)
7
+
8
+ """Fetches the text content of a given URL.
9
+
10
+ This tool makes a simple GET request and returns the raw text content.
11
+ It does not render JavaScript or handle complex interactions."""
12
+
13
+ @FunctionRegistry.register
14
+ class GetUrlContent(BaseTool):
15
+ def __init__(self, name="get_url_content"):
16
+ self.name = name
17
+
18
+ @property
19
+ def definition(self):
20
+ return {
21
+ "type": "function",
22
+ "function": {
23
+ "name": self.name,
24
+ "description": (
25
+ "Fetches the text content of a given URL. "
26
+ "This tool makes a simple GET request and returns the raw text content. "
27
+ "It does not render JavaScript or handle complex interactions."
28
+ ),
29
+ "parameters": {
30
+ "type": "object",
31
+ "properties": {
32
+ "url": {
33
+ "type": "string",
34
+ "description": "The URL to fetch content from (e.g., 'https://www.example.com')."
35
+ }
36
+ },
37
+ "required": ["url"]
38
+ }
39
+ }
40
+ }
41
+
42
+ def fn(self, url: str):
43
+ logger.debug(f"Attempting to fetch content from URL: {url}")
44
+ try:
45
+ headers = {
46
+ 'User-Agent': (
47
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) '
48
+ 'AppleWebKit/537.36 (KHTML, like Gecko) '
49
+ 'Chrome/91.0.4472.124 Safari/537.36'
50
+ )
51
+ }
52
+ response = requests.get(url, headers=headers, timeout=15)
53
+ response.raise_for_status()
54
+ logger.info(f"Successfully fetched content from URL: {url}")
55
+ return response.text
56
+ except requests.exceptions.HTTPError as e:
57
+ logger.error(f"HTTP error fetching URL {url}: {e}")
58
+ return f"Error: HTTP error - {e}"
59
+ except requests.exceptions.ConnectionError as e:
60
+ logger.error(f"Connection error fetching URL {url}: {e}")
61
+ return f"Error: Connection error - {e}"
62
+ except requests.exceptions.Timeout as e:
63
+ logger.error(f"Timeout fetching URL {url}: {e}")
64
+ return f"Error: Timeout - {e}"
65
+ except requests.exceptions.RequestException as e:
66
+ logger.error(f"Request error fetching URL {url}: {e}")
67
+ return f"Error: Request error - {e}"
68
+ except Exception as e:
69
+ logger.error(f"Unexpected error fetching URL {url}: {e}")
70
+ return f"Error: Unexpected error - {e}"
File without changes
@@ -0,0 +1,74 @@
1
+ from ..base import BaseTool
2
+ from ..config import FunctionRegistry, ToolConfig
3
+ import logging
4
+ import requests
5
+ import os
6
+ import pdfplumber
7
+ from pdfminer.pdfparser import PDFSyntaxError
8
+
9
+ logger = logging.getLogger(__name__)
10
+
11
+ """
12
+ A tool for reading the text content from a PDF file.
13
+
14
+ This class provides a function that takes a file path to a PDF as input
15
+ and returns its text content as a string.
16
+ """
17
+
18
+ @FunctionRegistry.register
19
+ class ReadPdf(BaseTool) :
20
+ def __init__(self, name="pdf_reader"):
21
+ super().__init__()
22
+ self.name=name
23
+
24
+ @property
25
+ def definition(self):
26
+ return{
27
+ "type": "function",
28
+ "function": {
29
+ "name": self.name,
30
+ "description": "Read teh text content from a PDF file",
31
+ "parameters": {
32
+ "type": "object",
33
+ "properties": {
34
+ "file_path": {
35
+ "type": "string",
36
+ "description": "The local path to the PDF file to be read."
37
+ }
38
+ },
39
+ "required": ["file_path"]
40
+ }
41
+ }
42
+ }
43
+
44
+ def fn(self, file_path: str) -> str :
45
+ logger.debug(f"Reading PDF file: {file_path}")
46
+ try:
47
+ if not os.path.exists(file_path):
48
+ logger.error(f"File not found: {file_path}")
49
+ return f"Error: File not found at path '{file_path}'."
50
+ if not file_path.lower().endswith(".pdf"):
51
+ logger.error(f"File is not a PDF: {file_path}")
52
+ return f"Error: File '{file_path}' is not a PDF."
53
+
54
+ text_content = []
55
+ with pdfplumber.open(file_path) as pdf:
56
+ for page_num, page in enumerate(pdf.pages):
57
+ page_text = page.extract_text()
58
+ if page_text:
59
+ text_content.append(page_text)
60
+ else:
61
+ logger.debug(f"No text extracted from page {page_num+1} of {file_path}")
62
+
63
+ if not text_content:
64
+ logger.warning(f"No text could be extracted from the PDF: {file_path}")
65
+ return "No text content could be extracted from this PDF."
66
+
67
+ return "\n".join(text_content)
68
+
69
+ except PDFSyntaxError:
70
+ logger.error(f"Error parsing PDF (syntax error): {file_path}")
71
+ return f"Error: Could not parse PDF file '{file_path}'. It might be corrupted or not a valid PDF."
72
+ except Exception as e:
73
+ logger.error(f"An unexpected error occurred while reading PDF '{file_path}': {e}", exc_info=True)
74
+ return f"Error reading PDF file '{file_path}': {e}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: gofannon
3
- Version: 0.25.21
3
+ Version: 0.25.23
4
4
  Summary: A collection of tools for LLMs
5
5
  License: ASFv2
6
6
  Author: Trevor Grant
@@ -3,7 +3,7 @@ gofannon/arxiv/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  gofannon/arxiv/get_article.py,sha256=SRGTXFXdXdXTIOLZKWUTXxZEYEqZFWFJEV2nTsU5qqU,1167
4
4
  gofannon/arxiv/search.py,sha256=37Zx1y2vAX1xYIKaAxzBGXE3qPHUZdAD2XR0H1Acs-4,4225
5
5
  gofannon/base/__init__.py,sha256=n2tWf7udXSXfREsxXD0E8kOY--X-ffGTNsdMwk2V33A,3814
6
- gofannon/base/adk_mixin.py,sha256=GTvbCb-LLGPF5LUkf011lKq_JI1CB0n9K5ch_W0pAlk,13322
6
+ gofannon/base/adk_mixin.py,sha256=AR9dd9sdQ1KSrs2gXVExl7_Z4DUG3xwf3rVa2q66Ok0,13520
7
7
  gofannon/base/bedrock.py,sha256=Z2c36R8jaIusgpmegbYVz2eR7lDBc0IhTtwiqUGOcT4,25646
8
8
  gofannon/base/langchain.py,sha256=25z9opy7E7qWP-DSn6oYAqKDg8i21az-kAKrsYLfyiQ,2704
9
9
  gofannon/base/langflow.py,sha256=0WfNJ9MnndyLJ-yUAStIuXZpCzOPItsGKgtxdNifmLM,3833
@@ -21,6 +21,8 @@ gofannon/file/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
21
21
  gofannon/file/list_directory.py,sha256=Jw0F50_hdtyDSFBmcy9e8F4KajtsPyT8Gsm_eyjMUuQ,2679
22
22
  gofannon/file/read_file.py,sha256=kYf-4aGCHLj-D-XQs0YBEnbB1MbIccgcWbiLnVXidp4,1669
23
23
  gofannon/file/write_file.py,sha256=fQ5P4cqZKdoq8Bk7nys2Esau0Q5WvbeY8srGvfx36NQ,1495
24
+ gofannon/get_url_content/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
+ gofannon/get_url_content/get_url_content.py,sha256=Bj1TUUhaAB6Ts783rCEJQxTd-gq-eWFuT-Ao6Nx3CKo,2754
24
26
  gofannon/github/__init__.py,sha256=VFw4sJIt4Zc0-__eYnksN8Ku9qMhbPpHJEkXMWUiD30,4
25
27
  gofannon/github/clone_repo.py,sha256=UNXh1JaZkzK94REJUfQrBAhF66ncFWkzcZj34Si34cI,2287
26
28
  gofannon/github/commit_file.py,sha256=jdQGQHbrZx4521XgTbx5N0Ss8fDyl7hvp9sjDW15v9U,2573
@@ -43,6 +45,8 @@ gofannon/open_notify_space/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74
43
45
  gofannon/open_notify_space/iss_locator.py,sha256=STLNSD5HriRR6grpRpiTRDbqVRtWMPVoGuV8SygHGNY,4734
44
46
  gofannon/orchestration/__init__.py,sha256=_p_XhWHgOIgiamFSGwFUqrnBlIYDvQMq5L5mxJvxiks,5121
45
47
  gofannon/orchestration/firebase_wrapper.py,sha256=jXqUcIoKuTC_1ZffN3v1DN9X6of-OuMKWP8ZzQ-wHOU,1394
48
+ gofannon/pdf_reader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ gofannon/pdf_reader/pdf_reader.py,sha256=yBFzB8V_dMyZVqFm7zMiuD7X-VHb0dlSLNo3VlFCOzY,2808
46
50
  gofannon/reasoning/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
51
  gofannon/reasoning/base.py,sha256=D-4JHJqUlqgwMNOkKU0BHYA4GEWwNgPlLxKYHX0FVyg,1494
48
52
  gofannon/reasoning/hierarchical_cot.py,sha256=e8ZgMbyJQ0wCBEmv7QJqFv7l3XxTMwDYupGxJ7EF6t8,11516
@@ -65,7 +69,7 @@ gofannon/simpler_grants_gov/search_base.py,sha256=ask8ecAOQ9jZulr8iDxdfQZgSC_Eyx
65
69
  gofannon/simpler_grants_gov/search_opportunities.py,sha256=jZD64VqFIW36dBdAshOOQmywzLqBZyB3wLtA_C95sa8,19931
66
70
  gofannon/wikipedia/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
71
  gofannon/wikipedia/wikipedia_lookup.py,sha256=J6wKPbSivCF7cccaiRaJW1o0VqNhQAGfrh5U1ULLesg,2869
68
- gofannon-0.25.21.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
69
- gofannon-0.25.21.dist-info/METADATA,sha256=LMaFBOVKh41jLmEPujIquU9hJbPNv-PnYjf7Eo3qaiI,5427
70
- gofannon-0.25.21.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
71
- gofannon-0.25.21.dist-info/RECORD,,
72
+ gofannon-0.25.23.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
73
+ gofannon-0.25.23.dist-info/METADATA,sha256=F2kTD2HULTiZv9_k4br2l-lYY1ra_t8h11wihqEUhIE,5427
74
+ gofannon-0.25.23.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
75
+ gofannon-0.25.23.dist-info/RECORD,,