-
Notifications
You must be signed in to change notification settings - Fork 3
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 #3 from Vokturz/agents
Agents
- Loading branch information
Showing
9 changed files
with
673 additions
and
60 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
chromadb==0.3.25 | ||
langchain==0.0.205 | ||
langchain==0.0.231 | ||
python-dotenv==1.0.0 | ||
slack_bolt==1.18.0 | ||
tiktoken==0.4.0 | ||
|
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,36 @@ | ||
from langchain.tools import tool, DuckDuckGoSearchRun, ArxivQueryRun | ||
from concurrent.futures import ThreadPoolExecutor | ||
import asyncio | ||
import subprocess | ||
@tool | ||
def disk_usage(query: str) -> str: | ||
"""useful for when you need to answer questions about the disk usage.""" | ||
output = subprocess.check_output(['df', '-h'], text=True) | ||
output = "This is the output of `df -h`:\n" + output | ||
return output | ||
|
||
@tool | ||
def memory_usage(query: str) -> str: | ||
"""useful for when you need to answer questions about memory usage.""" | ||
output = subprocess.check_output(['free', '-h'], text=True) | ||
output = "This is the output of `free -h`. Mem refers to RAM memory and Swap to swap memory:\n" + output | ||
return output | ||
|
||
class asyncDuckDuckGoSearchRun(DuckDuckGoSearchRun): | ||
# max number of parallel requests | ||
max_workers: int = 2 | ||
async def _arun(self,query: str) -> str: | ||
"""Use the tool asynchronously.""" | ||
executor = ThreadPoolExecutor(max_workers=self.max_workers) | ||
results = await asyncio.get_running_loop().run_in_executor(executor, self._run, query) | ||
return results | ||
|
||
class asyncArxivQueryRun(ArxivQueryRun): | ||
# max number of parallel requests | ||
max_workers: int = 2 | ||
async def _arun(self, query: str) -> str: | ||
"""Use the tool asynchronously.""" | ||
executor = ThreadPoolExecutor(max_workers=self.max_workers) | ||
results = await asyncio.get_running_loop().run_in_executor(executor, self._run, query) | ||
return results | ||
|
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
Oops, something went wrong.