fix: Debugging integration

pull/65/head
Zack 1 year ago
parent b61aa635df
commit a858bd9c72

@ -0,0 +1,19 @@
from swarms.models.bing_chat import BingChat
from swarms.workers.worker import Worker
from swarms.tools.autogpt import EdgeGPTTool, tool
# Initialize the language model,
# This model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC
llm = BingChat(cookies_path="./cookies.json")
# Initialize the Worker with the custom tool
worker = Worker(
llm=llm,
ai_name="EdgeGPT Worker",
)
# Use the worker to process a task
task = "Hello, my name is ChatGPT"
response = worker.run(task)
print(response)

@ -0,0 +1,6 @@
[
{
"name": "cookie1",
"value": "1GJjj1-tM6Jlo4HFtnbocQ3r0QbQ9Aq_R65dqbcSWKzKxnN8oEMW1xa4RlsJ_nGyNjFlXQRzMWRR2GK11bve8-6n_bjF0zTczYcQQ8oDB8W66jgpIWSL7Hr4hneB0R9dIt-OQ4cVPs4eehL2lcRCObWQr0zkG14MHlH5EMwAKthv_NNIQSfThq4Ey2Hmzhq9sRuyS04JveHdLC9gfthJ8xk3J12yr7j4HsynpzmvFUcA"
}
]

@ -1,17 +1,31 @@
from swarms.models.bing_chat import EdgeGPTModel
from swarms.models.bing_chat import BingChat
from swarms.workers.worker import Worker
from swarms.tools.tool import EdgeGPTTool
from swarms.tools.autogpt import EdgeGPTTool, tool
from swarms.models import OpenAIChat
import os
api_key = os.getenv("OPENAI_API_KEY")
# Initialize the EdgeGPTModel
edgegpt = EdgeGPTModel(cookies_path="./cookies.txt")
edgegpt = BingChat(cookies_path="./cookies.txt")
@tool
def edgegpt(task: str = None):
"""A tool to run infrence on the EdgeGPT Model"""
return EdgeGPTTool.run(task)
# Initialize the custom tool
edgegpt_tool = EdgeGPTTool(edgegpt)
# Initialize the language model,
# This model can be swapped out with Anthropic, ETC, Huggingface Models like Mistral, ETC
llm = OpenAIChat(
openai_api_key=api_key,
temperature=0.5,
)
# Initialize the Worker with the custom tool
worker = Worker(
llm=llm,
ai_name="EdgeGPT Worker",
external_tools=[edgegpt_tool],
external_tools=[edgegpt]
)
# Use the worker to process a task

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

@ -1,2 +1,2 @@
from swarms.structs.workflow import Workflow
from swarms.structs.task import Task
# from swarms.structs.workflow import Workflow
# from swarms.structs.task import Task

@ -7,7 +7,7 @@ from abc import ABC, abstractmethod
from enum import Enum
from typing import Any, List, Optional, Union
from pydantic import BaseModel, Field, StrictStr, conlist
from pydantic import BaseModel, Field, StrictStr
from swarms.artifacts.main import Artifact
from swarms.artifacts.error_artifact import ErrorArtifact
@ -137,9 +137,6 @@ class Task(BaseModel):
None, description="Input parameters for the task. Any value is allowed"
)
task_id: StrictStr = Field(..., description="ID of the task")
artifacts: conlist(Artifact, min_items=1) = Field(
..., description="A list of artifacts that the task has been produced"
)
class Config:
allow_population_by_field_name = True

@ -142,6 +142,19 @@ class WebpageQATool(BaseTool):
async def _arun(self, url: str, question: str) -> str:
raise NotImplementedError
class EdgeGPTTool:
# Initialize the custom tool
def __init__(
self,
model,
name="EdgeGPTTool",
description="Tool that uses EdgeGPTModel to generate responses",
):
super().__init__(name=name, description=description)
self.model = model
def _run(self, prompt):
return self.model.__call__(prompt)
@tool
def VQAinference(self, inputs):

@ -1,9 +0,0 @@
from swarms.tools.tool import BaseTool
class EdgeGPTTool(BaseTool):
def __init__(self, model, name="EdgeGPTTool", description="Tool that uses EdgeGPTModel to generate responses"):
super().__init__(name=name, description=description)
self.model = model
def _run(self, prompt):
return self.model.__call__(prompt)
Loading…
Cancel
Save