feat: Add bing tools and example

pull/64/head
Zack 1 year ago
parent 9dfbdee71e
commit 6cb595d956

@ -0,0 +1,20 @@
from swarms.models.bing_chat import EdgeGPTModel
from swarms.workers.worker import Worker
from swarms.tools.tool.bing_chat import EdgeGPTTool
# Initialize the EdgeGPTModel
edgegpt = EdgeGPTModel(cookies_path="./path/to/cookies.json")
# Initialize the custom tool
edgegpt_tool = EdgeGPTTool(edgegpt)
# Initialize the Worker with the custom tool
worker = Worker(
ai_name="EdgeGPT Worker",
external_tools=[edgegpt_tool],
)
# Use the worker to process a task
task = "Hello, my name is ChatGPT"
response = worker.run(task)
print(response)

@ -6,6 +6,7 @@ langchain
nest_asyncio
pegasusx
google-generativeai
EdgeGPT
langchain-experimental
playwright
wget==3.2

@ -26,7 +26,7 @@ class EdgeGPTModel:
self.cookies = json.loads(open(cookies_path, encoding="utf-8").read())
self.bot = asyncio.run(Chatbot.create(cookies=self.cookies))
def __call(self, prompt: str, style: ConversationStyle = ConversationStyle.creative) -> str:
def __call__(self, prompt: str, style: ConversationStyle = ConversationStyle.creative) -> str:
"""
Get a text response using the EdgeGPT model based on the provided prompt.
"""

@ -576,7 +576,13 @@ class Tool(BaseTool):
args_schema=args_schema,
**kwargs,
)
class EdgeGPTTool:
def __init__(self, model):
self.model = model
def run(self, prompt):
return self.model.ask(prompt)
class StructuredTool(BaseTool):
"""Tool that can operate on any number of inputs."""

Loading…
Cancel
Save