Former-commit-id: ec8b8be28d
pull/47/head 1.1.1
Kye 1 year ago
parent c52a92f443
commit 9ebb51aa94

@ -1,4 +1,4 @@
## Swarming AI Agents (Swarms) ## Swarms of Autonomous AI Agents
![Swarming banner](images/swarms.png) ![Swarming banner](images/swarms.png)

@ -24,7 +24,7 @@ from langchain.schema import (
NoOpOutputParser, NoOpOutputParser,
PromptValue, PromptValue,
) )
from langchain.schema.language_model import BaseLanguageModel from langchain.base_language import BaseLanguageModel
class LLMChain(Chain): class LLMChain(Chain):

@ -7,8 +7,6 @@ from dataclasses import dataclass
from io import BytesIO from io import BytesIO
from typing import Any, List, Optional, Sequence, Tuple, Union from typing import Any, List, Optional, Sequence, Tuple, Union
from pydantic import BaseModel, BaseSettings, root_validator
from langchain.agents import AgentExecutor, BaseSingleActionAgent from langchain.agents import AgentExecutor, BaseSingleActionAgent
from langchain.base_language import BaseLanguageModel from langchain.base_language import BaseLanguageModel
from langchain.callbacks import AsyncIteratorCallbackHandler from langchain.callbacks import AsyncIteratorCallbackHandler
@ -36,8 +34,7 @@ from langchain.schema import (
) )
from langchain.tools import BaseTool, StructuredTool from langchain.tools import BaseTool, StructuredTool
from langchain.tools.convert_to_openai import format_tool_to_openai_function from langchain.tools.convert_to_openai import format_tool_to_openai_function
from pydantic import BaseModel, BaseSettings, root_validator
remove_dl_link_prompt = ChatPromptTemplate( remove_dl_link_prompt = ChatPromptTemplate(
input_variables=["input_response"], input_variables=["input_response"],
@ -295,7 +292,7 @@ class File(BaseModel):
return f"File(name={self.name})" return f"File(name={self.name})"
from langchain.schema import HumanMessage, AIMessage # type: ignore from langchain.schema import AIMessage, HumanMessage # type: ignore
class UserRequest(HumanMessage): class UserRequest(HumanMessage):

@ -8,9 +8,8 @@ from pathlib import Path
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union from typing import Any, Dict, List, Optional, Sequence, Tuple, Union
import yaml import yaml
from pydantic import BaseModel, root_validator
from langchain.agents.agent_types import AgentType from langchain.agents.agent_types import AgentType
from langchain.base_language import BaseLanguageModel
from langchain.callbacks.base import BaseCallbackManager from langchain.callbacks.base import BaseCallbackManager
from langchain.callbacks.manager import ( from langchain.callbacks.manager import (
AsyncCallbackManagerForToolRun, AsyncCallbackManagerForToolRun,
@ -26,9 +25,9 @@ from langchain.schema import (
BaseOutputParser, BaseOutputParser,
BasePromptTemplate, BasePromptTemplate,
) )
from langchain.schema.language_model import BaseLanguageModel
from langchain.schema.messages import BaseMessage from langchain.schema.messages import BaseMessage
from langchain.tools.base import BaseTool from langchain.tools.base import BaseTool
from pydantic import BaseModel, root_validator
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

@ -1,12 +1,13 @@
from typing import Any, Dict, List, Optional, Union from typing import Any, Dict, List, Optional, Union
from celery import Task
from langchain.callbacks.base import BaseCallbackHandler from langchain.callbacks.base import BaseCallbackHandler
from langchain.schema import AgentAction, AgentFinish, LLMResult from langchain.schema import AgentAction, AgentFinish, LLMResult
from celery import Task
from swarms.utils.logger import logger
# from ansi import ANSI, Color, Style, dim_multiline # from ansi import ANSI, Color, Style, dim_multiline
from swarms.utils.main import ANSI, Color, Style, dim_multiline from swarms.utils.main import ANSI, Color, Style, dim_multiline
from swarms.utils.logger import logger
class EVALCallbackHandler(BaseCallbackHandler): class EVALCallbackHandler(BaseCallbackHandler):

@ -1,13 +1,12 @@
"""OpenAI chat wrapper.""" """OpenAI chat wrapper."""
from __future__ import annotations from __future__ import annotations
import os
import logging import logging
import os
import sys import sys
from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple from typing import Any, Callable, Dict, List, Mapping, Optional, Tuple
import openai import openai
from langchain.chat_models.base import BaseChatModel from langchain.chat_models.base import BaseChatModel
from langchain.schema import ( from langchain.schema import (
AIMessage, AIMessage,
@ -18,9 +17,7 @@ from langchain.schema import (
HumanMessage, HumanMessage,
SystemMessage, SystemMessage,
) )
from langchain.utils import get_from_dict_or_env from langchain.utils import get_from_dict_or_env
from swarms.utils.logger import logger
from pydantic import BaseModel, Extra, Field, root_validator from pydantic import BaseModel, Extra, Field, root_validator
from tenacity import ( from tenacity import (
before_sleep_log, before_sleep_log,
@ -30,10 +27,11 @@ from tenacity import (
wait_exponential, wait_exponential,
) )
from swarms.utils.logger import logger
# from ansi import ANSI, Color, Style # from ansi import ANSI, Color, Style
from swarms.utils.main import ANSI, Color, Style from swarms.utils.main import ANSI, Color, Style
import os
def _create_retry_decorator(llm: ChatOpenAI) -> Callable[[Any], Any]: def _create_retry_decorator(llm: ChatOpenAI) -> Callable[[Any], Any]:
import openai import openai

@ -1,10 +1,10 @@
from typing import Any, List, Optional, Sequence, Tuple
import logging import logging
from typing import Any, List, Optional, Sequence, Tuple
from swarms.agents.utils.Agent import Agent from langchain.agents.agent import AgentOutputParser
from langchain.base_language import BaseLanguageModel
from langchain.callbacks.base import BaseCallbackManager from langchain.callbacks.base import BaseCallbackManager
from langchain.chains import LLMChain from langchain.chains import LLMChain
from langchain.schema import BaseOutputParser
from langchain.prompts.base import BasePromptTemplate from langchain.prompts.base import BasePromptTemplate
from langchain.prompts.chat import ( from langchain.prompts.chat import (
ChatPromptTemplate, ChatPromptTemplate,
@ -15,20 +15,14 @@ from langchain.prompts.chat import (
from langchain.schema import ( from langchain.schema import (
AgentAction, AgentAction,
AIMessage, AIMessage,
BaseLanguageModel,
BaseMessage, BaseMessage,
BaseOutputParser,
HumanMessage, HumanMessage,
) )
from langchain.tools.base import BaseTool from langchain.tools.base import BaseTool
from langchain.agents.agent import AgentOutputParser
from langchain.schema import AgentAction
from swarms.agents.prompts.prompts import EVAL_TOOL_RESPONSE from swarms.agents.prompts.prompts import EVAL_TOOL_RESPONSE
from swarms.agents.utils.Agent import Agent
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

@ -1,21 +1,19 @@
import os import os
from swarms.agents.prompts.prompts import EVAL_PREFIX, EVAL_SUFFIX from langchain.callbacks.base import BaseCallbackManager
from swarms.agents.tools.main import BaseToolSet
from swarms.agents.tools.main import ToolsFactory
# from .ChatOpenAI import ChatOpenAI
from langchain.chat_models import ChatOpenAI
from langchain.chat_models.base import BaseChatModel from langchain.chat_models.base import BaseChatModel
from langchain.schema import BaseOutputParser from langchain.schema import BaseOutputParser
from langchain.callbacks.base import BaseCallbackManager
from swarms.agents.prompts.prompts import EVAL_PREFIX, EVAL_SUFFIX
from swarms.agents.tools.main import BaseToolSet, ToolsFactory
from .ConversationalChatAgent import ConversationalChatAgent from .ConversationalChatAgent import ConversationalChatAgent
# from .ChatOpenAI import ChatOpenAI
from langchain.chat_models import ChatOpenAI
from .output_parser import EvalOutputParser from .output_parser import EvalOutputParser
class AgentSetup: class AgentSetup:
def __init__(self, toolsets: list[BaseToolSet] = [], openai_api_key: str = None, serpapi_api_key: str = None, bing_search_url: str = None, bing_subscription_key: str = None): def __init__(self, toolsets: list[BaseToolSet] = [], openai_api_key: str = None, serpapi_api_key: str = None, bing_search_url: str = None, bing_subscription_key: str = None):
self.llm: BaseChatModel = None self.llm: BaseChatModel = None

@ -3,16 +3,14 @@ import re
from datetime import datetime from datetime import datetime
from typing import Any, Dict, List, Optional from typing import Any, Dict, List, Optional
from langchain import LLMChain
from langchain.base_language import BaseLanguageModel
############ ############
from langchain.prompts import PromptTemplate from langchain.prompts import PromptTemplate
from langchain.retrievers import TimeWeightedVectorStoreRetriever from langchain.retrievers import TimeWeightedVectorStoreRetriever
from langchain.schema import BaseMemory, Document from langchain.schema import BaseMemory, Document
from langchain.schema.language_model import BaseLanguageModel
from langchain.utils import mock_now from langchain.utils import mock_now
from langchain import LLMChain
from langchain.schema.language_model import BaseLanguageModel
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

Loading…
Cancel
Save