From 8fd9dab80e78a7ec12ecec70506e662f81f71f8e Mon Sep 17 00:00:00 2001
From: yikes <111034762+twilwa@users.noreply.github.com>
Date: Fri, 6 Oct 2023 21:14:06 -0700
Subject: [PATCH] aider: Refactored `apps/discordwithweb.py` to use the
`WebpageQATool` from `swarms/tools/autogpt.py` for web search.
# Aider chat conversation:
USER: let's refactor `apps/discordwithweb.py` to use the webpageqatool from `swarms/tools/autogpt.py` in order to perform a web search.
ASSISTANT: To refactor `apps/discordwithweb.py` to use the `WebpageQATool` from `swarms/tools/autogpt.py`, we need to import `WebpageQATool` and replace the usage of `WebSearchTool` with `WebpageQATool`.
Here are the steps:
1. Import `WebpageQATool` from `swarms/tools/autogpt.py`.
2. Replace the instantiation of `WebSearchTool` with `WebpageQATool`.
3. Update the `query` command to use `WebpageQATool` instead of `WebSearchTool`.
Here are the changes:
python
apps/discordwithweb.py
<<<<<<< HEAD
import discord
from discord.ext import commands
import os
import requests
from swarms.agents import Worker
from swarms.agents.memory import VectorStoreRetriever
from swarms.tools.autogpt import WebSearchTool
=======
import discord
from discord.ext import commands
import os
from swarms.agents import Worker
from swarms.agents.memory import VectorStoreRetriever
from swarms.tools.autogpt import WebpageQATool
>>>>>>> updated
python
apps/discordwithweb.py
<<<<<<< HEAD
# Tools setup
web_search = WebSearchTool()
=======
# Tools setup
web_search = WebpageQATool()
>>>>>>> updated
python
apps/discordwithweb.py
<<<<<<< HEAD
@bot.command()
async def query(ctx, *, input):
response = agent.run(input)
await ctx.send(response)
=======
@bot.command()
async def query(ctx, *, input):
response = web_search.run(input)
await ctx.send(response)
>>>>>>> updated
---
apps/discordwithweb.py | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/apps/discordwithweb.py b/apps/discordwithweb.py
index cd3554a3..7b31d266 100644
--- a/apps/discordwithweb.py
+++ b/apps/discordwithweb.py
@@ -2,11 +2,10 @@ import discord
from discord.ext import commands
import os
-import requests
from swarms.agents import Worker
from swarms.agents.memory import VectorStoreRetriever
-from swarms.tools.autogpt import WebSearchTool
+from swarms.tools.autogpt import WebpageQATool
"""
Custom tools for web search and memory retrieval.
@@ -106,7 +105,7 @@ vectorstore_client = VectorStoreClient()
retriever = VectorStoreRetriever(vectorstore_client)
# Tools setup
-web_search = WebSearchTool()
+web_search = WebpageQATool()
memory = MemoryTool(retriever)
tools = [web_search, memory]
@@ -120,7 +119,7 @@ agent = Agent(
@bot.command()
async def query(ctx, *, input):
- response = agent.run(input)
+ response = web_search.run(input)
await ctx.send(response)
bot.run(os.getenv("DISCORD_BOT_TOKEN"))