Skip to content

Commit

Permalink
Update tool.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximilian-Winter committed May 26, 2024
1 parent 55ef26d commit db2a8fb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/llama_cpp_agent/tools/web_search/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ def search_web(self, search_query: str):
if self.max_tokens_search_results < len(tokens):
remove_chars = len(tokens) - self.max_tokens_search_results
while True:
tokens = self.llm_provider.tokenize(res[:remove_chars])
tokens = self.llm_provider.tokenize(res[:-remove_chars])
if self.max_tokens_search_results >= len(tokens):
break
else:
remove_chars += 100

return "\nResults of searching the web:\n\n" + res[:remove_chars]
return "\nResults of searching the web:\n\n" + res[:-remove_chars]

def get_tool(self):
return self.search_web
Expand Down

0 comments on commit db2a8fb

Please sign in to comment.