clean up swarms

pull/53/head
Kye 1 year ago
parent e19b78cf60
commit 3aeb7b96ae

@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
[tool.poetry]
name = "swarms"
version = "1.4.0"
version = "1.4.3"
description = "Swarms - Pytorch"
license = "MIT"
authors = ["Kye Gomez <kye@apac.ai>"]

@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name = 'swarms',
packages = find_packages(exclude=[]),
version = '1.3.3',
version = '1.4.1',
license='MIT',
description = 'Swarms - Pytorch',
author = 'Kye Gomez',

@ -1,10 +1,10 @@
#swarms
# worker
from swarms.workers.worker_node import WorkerNode
# from swarms.workers.worker_node import WorkerNode
#boss
from swarms.boss.boss_node import BossNode
# from swarms.boss.boss_node import BossNode
#models
from swarms.agents.models.anthropic import Anthropic

@ -4,7 +4,7 @@ from typing import List, Optional
from langchain.chains.llm import LLMChain
from pydantic import ValidationError
# from pydantic import ValidationError
from swarms.agents.memory.base import VectorStoreRetriever
from swarms.agents.memory.base_memory import BaseChatMessageHistory, ChatMessageHistory
@ -106,9 +106,9 @@ class Agent:
tool = tools[action.name]
try:
observation = tool.run(action.args)
except ValidationError as e:
except Exception as error:
observation = (
f"Validation Error in args: {str(e)}, args: {action.args}"
f"Validation Error in args: {str(error)}, args: {action.args}"
)
except Exception as e:
observation = (

@ -1,5 +1,5 @@
from typing import Any, Dict, List
from pydantic import Field
# from pydantic import Field
from swarms.agents.memory.base_memory import BaseChatMemory, get_prompt_input_key
from swarms.agents.memory.base import VectorStoreRetriever

@ -50,3 +50,6 @@ class HuggingFaceLLM:
except Exception as e:
self.logger.error(f"Failed to generate the text: {e}")
raise

@ -1,8 +1,8 @@
import logging
from typing import List, Optional, Union
from typing import List, Optional, Union, Any
import faiss
# from langchain.agents import Tool
from langchain.agents import Tool
from langchain.chat_models import ChatOpenAI
from langchain.docstore import InMemoryDocstore
from langchain.embeddings import OpenAIEmbeddings
@ -39,7 +39,7 @@ class WorkerNodeInitializer:
def __init__(self,
openai_api_key: str,
llm: Optional[Union[InMemoryDocstore, ChatOpenAI]] = None,
tools: Optional[List[Tool]] = None,
tools: Optional[List[Any]] = None,
embedding_size: Optional[int] = 8192,
worker_name: Optional[str] = "Swarm Worker AI Assistant",
worker_role: Optional[str] = "Assistant",
@ -119,14 +119,13 @@ class WorkerNodeInitializer:
raise e
#####################
class WorkerNode:
def __init__(self,
openai_api_key: str,
temperature: Optional[int] = None,
llm: Optional[Union[InMemoryDocstore, ChatOpenAI]] = None,
tools: Optional[List[Tool]] = None,
tools: Optional[List[Any]] = None,
embedding_size: Optional[int] = 8192,
worker_name: Optional[str] = "Swarm Worker AI Assistant",
worker_role: Optional[str] = "Assistant",
@ -170,7 +169,7 @@ class WorkerNode:
logging.error(f"Error while creating agent: {str(e)}")
raise e
def add_tool(self, tool: Optional[Tool] = None):
def add_tool(self, tool: Optional[Any] = None):
if tool is None:
tool = DuckDuckGoSearchRun()
@ -270,14 +269,15 @@ class WorkerNode:
logging.error(f"Failed to create worker node: {e}")
raise
def worker_node(openai_api_key):
def worker_node(openai_api_key, objective):
if not openai_api_key:
logging.error("OpenAI API key is not provided")
raise ValueError("OpenAI API key is required")
try:
worker_node = WorkerNode(openai_api_key)
return worker_node.create_worker_node()
worker_node.create_worker_node()
return worker_node.run(objective)
except Exception as e:
logging.error(f"An error occured in worker_node: {e}")
raise
Loading…
Cancel
Save