Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updating example #20

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions example/SearchActions.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os

from langchain_community.tools import DuckDuckGoSearchResults, WikipediaQueryRun
from langchain_community.utilities import WikipediaAPIWrapper
import wikipedia
import duckduckgo_search

from agentlite.actions.BaseAction import BaseAction

Expand All @@ -11,25 +11,28 @@ def __init__(self) -> None:
action_name = "DuckDuckGo_Search"
action_desc = "Using this action to search online content."
params_doc = {"query": "the search string. be simple."}
self.search = DuckDuckGoSearchResults()
self.ddgs = duckduckgo_search.DDGS()
super().__init__(
action_name=action_name, action_desc=action_desc, params_doc=params_doc,
)

def __call__(self, query):
return self.search.run(query)


results = self.ddgs.chat(query)
return results
class WikipediaSearch(BaseAction):
def __init__(self) -> None:
action_name = "Wikipedia_Search"
action_desc = "Using this API to search Wiki content."
params_doc = {"query": "the search string. be simple."}

self.search = WikipediaQueryRun(api_wrapper=WikipediaAPIWrapper())
super().__init__(
action_name=action_name, action_desc=action_desc, params_doc=params_doc,
)

def __call__(self, query):
return self.search.run(query)
search_results = wikipedia.search(query)
if not search_results:
return "No results found."
article = wikipedia.page(search_results[0])
return article.summary
3 changes: 2 additions & 1 deletion example/SearchAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def test_search_agent():
# role = "searching online content"
# labor_agent = SearchAgent(name=name, role=role, llm=llm, actions=actions)
## test the one-shot wikipedia search agent
labor_agent = WikiSearchAgent(llm=llm)
# labor_agent = WikiSearchAgent(llm=llm)
labor_agent = DuckSearchAgent(llm=llm)

test_task = "what is the found date of microsoft"
test_task_pack = TaskPackage(instruction=test_task)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pydantic
## example dependencies
numpy
wikipedia
duckduckgo-search
duckduckgo-search==6.1.0
openmeteo_requests==1.2.0
requests_cache==1.2.0
retry_requests==2.0.0
Expand Down