post-PR changes

Requirements fix, knowledge tool error handling

frdel committed Aug 12, 2024 at 23:31 UTC f5f2a02d6719b5a514450d054685694787b6e597
3 files changed +20 -7
python/helpers/docker.py
+2 -2
@@ -1,13 +1,13 @@
1 import time
2 import docker
3 import atexit
4 -from typing import Dict, Optional
4 +from typing import Optional
5 from python.helpers.files import get_abs_path
6 from python.helpers.errors import format_error
7 from python.helpers.print_style import PrintStyle
8
9 class DockerContainerManager:
10 - def __init__(self, image: str, name: str, ports: Optional[Dict[str, int]] = None, volumes: Optional[Dict[str, Dict[str, str]]] = None):
10 + def __init__(self, image: str, name: str, ports: Optional[dict[str, int]] = None, volumes: Optional[dict[str, dict[str, str]]] = None):
11 self.image = image
12 self.name = name
13 self.ports = ports
python/tools/knowledge_tool.py
+14 -3
@@ -31,9 +31,20 @@ class Knowledge(Tool):
31 future_memory = executor.submit(memory_tool.search, self.agent, question)
32
33 # Wait for both functions to complete
34 - perplexity_result = (perplexity.result() if perplexity else "")
35 - duckduckgo_result = duckduckgo.result()
36 - memory_result = future_memory.result()
34 + try:
35 + perplexity_result = (perplexity.result() if perplexity else "") or ""
36 + except Exception as e:
37 + perplexity_result = "Perplexity search failed: " + str(e)
38 +
39 + try:
40 + duckduckgo_result = duckduckgo.result()
41 + except Exception as e:
42 + duckduckgo_result = "DuckDuckGo search failed: " + str(e)
43 +
44 + try:
45 + memory_result = future_memory.result()
46 + except Exception as e:
47 + memory_result = "Memory search failed: " + str(e)
48
49 msg = files.read_file("prompts/tool.knowledge.response.md",
50 online_sources = ((perplexity_result + "\n\n") if perplexity else "") + str(duckduckgo_result),
requirements.txt
+4 -2
@@ -13,5 +13,7 @@ docker==7.1.0
13 paramiko==3.4.0
14 duckduckgo_search==6.1.12
15 inputimeout==1.0.4
16 -newspaper==0.1.0.7
17 -beautifulsoup4=4.12.3
16 +newspaper3k==0.2.8
17 +beautifulsoup4==4.12.3
18 +lxml_html_clean==0.2.0
19 +