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:

<source>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
</source>

<source>python
apps/discordwithweb.py
<<<<<<< HEAD
# Tools setup
web_search = WebSearchTool()
=======
# Tools setup
web_search = WebpageQATool()
>>>>>>> updated
</source>

<source>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
</source>
pull/57/head
yikes 2 years ago
parent 088dbcdec1
commit 8fd9dab80e

@ -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"))

Loading…
Cancel
Save