-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from RSS3-Network/chore/env
chore: refactor expert loading
- Loading branch information
Showing
5 changed files
with
111 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import Optional, Type | ||
|
||
import requests | ||
from langchain.callbacks.manager import ( | ||
AsyncCallbackManagerForToolRun, | ||
CallbackManagerForToolRun, | ||
) | ||
from langchain.tools import BaseTool | ||
from pydantic import BaseModel, Field | ||
|
||
from openagent.conf.env import settings | ||
|
||
|
||
class DuneSchema(BaseModel): | ||
query: str = Field(description="The search query keywords for Dune dashboard search.") | ||
|
||
|
||
async def dune_search(query: str) -> str: | ||
url = f"{settings.RSS3_SEARCH_API}/dune/search?keyword={query}" | ||
headers = {"Accept": "*/*", "Content-Type": "application/x-www-form-urlencoded"} | ||
response = requests.request("GET", url, headers=headers) | ||
return response.text | ||
|
||
|
||
class DuneExpert(BaseTool): | ||
name = "DuneExecutor" | ||
description = """This tool searches for charts, data visualizations, and dashboards on Dune Analytics. \ | ||
Use this tool to find visual representations of blockchain data, trend analysis, and market overviews.""" | ||
args_schema: Type[DuneSchema] = DuneSchema | ||
|
||
def _run( | ||
self, | ||
query: str, | ||
run_manager: Optional[CallbackManagerForToolRun] = None, | ||
) -> str: | ||
raise NotImplementedError | ||
|
||
async def _arun( | ||
self, | ||
query: str, | ||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None, | ||
) -> str: | ||
return await dune_search(query) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from typing import Optional, Type | ||
|
||
from langchain import SerpAPIWrapper | ||
from langchain.callbacks.manager import ( | ||
AsyncCallbackManagerForToolRun, | ||
CallbackManagerForToolRun, | ||
) | ||
from langchain.tools import BaseTool | ||
from pydantic import BaseModel, Field | ||
|
||
|
||
class GoogleSchema(BaseModel): | ||
query: str = Field(description="The search query keywords for Google search.") | ||
|
||
|
||
async def google_search(query: str) -> str: | ||
search_wrapper = SerpAPIWrapper( | ||
search_engine="google", | ||
params={"engine": "google"}, | ||
) | ||
return search_wrapper.run(query) | ||
|
||
|
||
class GoogleExpert(BaseTool): | ||
name = "GoogleExecutor" | ||
description = """A versatile search tool that retrieves up-to-date information from the web. \ | ||
Use for current events, project details, fact-checking, and general research across various topics.""" | ||
args_schema: Type[GoogleSchema] = GoogleSchema | ||
|
||
def _run( | ||
self, | ||
query: str, | ||
run_manager: Optional[CallbackManagerForToolRun] = None, | ||
) -> str: | ||
raise NotImplementedError | ||
|
||
async def _arun( | ||
self, | ||
query: str, | ||
run_manager: Optional[AsyncCallbackManagerForToolRun] = None, | ||
) -> str: | ||
return await google_search(query) |
This file was deleted.
Oops, something went wrong.