jbollenbacher commited on
Commit
f229dcc
·
unverified ·
1 Parent(s): 32b562b

Update knowledge_tool.py

Browse files

Fixed behavior when Perplexity key is absent.

Files changed (1) hide show
  1. python/tools/knowledge_tool.py +4 -4
python/tools/knowledge_tool.py CHANGED
@@ -17,7 +17,7 @@ class Knowledge(Tool):
17
  with concurrent.futures.ThreadPoolExecutor() as executor:
18
  # Schedule the two functions to be run in parallel
19
 
20
- # perplexity search, if API provided
21
  if os.getenv("API_KEY_PERPLEXITY"):
22
  perplexity = executor.submit(perplexity_search.perplexity_search, question)
23
  else: perplexity = None
@@ -29,14 +29,14 @@ class Knowledge(Tool):
29
  future_memory = executor.submit(memory_tool.search, self.agent, question)
30
 
31
  # Wait for both functions to complete
32
- perplexity_result = (perplexity.result() if perplexity else "") or ""
33
  duckduckgo_result = duckduckgo.result()
34
  memory_result = future_memory.result()
35
 
36
  msg = files.read_file("prompts/tool.knowledge.response.md",
37
- online_sources = perplexity_result + "\n\n" + str(duckduckgo_result),
38
  memory = memory_result )
39
 
40
  if self.agent.handle_intervention(msg): pass # wait for intervention and handle it, if paused
41
 
42
- return Response(message=msg, break_loop=False)
 
17
  with concurrent.futures.ThreadPoolExecutor() as executor:
18
  # Schedule the two functions to be run in parallel
19
 
20
+ # perplexity search, if API key provided
21
  if os.getenv("API_KEY_PERPLEXITY"):
22
  perplexity = executor.submit(perplexity_search.perplexity_search, question)
23
  else: perplexity = None
 
29
  future_memory = executor.submit(memory_tool.search, self.agent, question)
30
 
31
  # Wait for both functions to complete
32
+ perplexity_result = (perplexity.result() if perplexity else "")
33
  duckduckgo_result = duckduckgo.result()
34
  memory_result = future_memory.result()
35
 
36
  msg = files.read_file("prompts/tool.knowledge.response.md",
37
+ online_sources = ((perplexity_result + "\n\n") if perplexity else "") + str(duckduckgo_result),
38
  memory = memory_result )
39
 
40
  if self.agent.handle_intervention(msg): pass # wait for intervention and handle it, if paused
41
 
42
+ return Response(message=msg, break_loop=False)