pull/393/head
Kye 11 months ago
parent 5758e6d575
commit 0d7fee779c

@ -22,7 +22,8 @@ class Qdrant:
collection_name: str = "qdrant",
model_name: str = "BAAI/bge-small-en-v1.5",
https: bool = True,
): ...
):
...
```
### Constructor Parameters

@ -27,7 +27,6 @@ from swarms.tokenizers import BaseTokenizer
class SimpleTokenizer(BaseTokenizer):
def count_tokens(self, text: Union[str, List[dict]]) -> int:
if isinstance(text, str):
# Split text by spaces as a simple tokenization approach

@ -3,7 +3,7 @@ import os
from dotenv import load_dotenv
from swarms import GPT4VisionAPI, Agent
from swarms import Agent, GPT4VisionAPI
# Load the environment variables
load_dotenv()

@ -1,6 +1,7 @@
from swarms.agents.multion_agent import MultiOnAgent
import timeit
from swarms import Agent, ConcurrentWorkflow, Task
from swarms.agents.multion_agent import MultiOnAgent
# model
model = MultiOnAgent(multion_api_key="api-key")

@ -1,6 +1,5 @@
from swarms.memory import ChromaDB
# Initialize the memory
chroma = ChromaDB(
metric="cosine",

@ -1,5 +1,5 @@
from swarms.models import OpenAIChat
from swarms import DialogueSimulator, Worker
from swarms.models import OpenAIChat
llm = OpenAIChat(
model_name="gpt-4", openai_api_key="api-key", temperature=0.5

@ -2,8 +2,8 @@ import os
from dotenv import load_dotenv
from swarms.models import Anthropic, Gemini, Mixtral, OpenAIChat
from swarms import ModelParallelizer
from swarms.models import Anthropic, Gemini, Mixtral, OpenAIChat
load_dotenv()

@ -1,6 +1,7 @@
import os
from dotenv import load_dotenv
from swarms import Agent, OpenAIChat
from swarms.agents.multion_agent import MultiOnAgent
from swarms.memory.chroma_db import ChromaDB

@ -1,6 +1,6 @@
from swarms import OpenAIChat
from swarms.structs.agent import Agent
from swarms.structs.message_pool import MessagePool
from swarms import OpenAIChat
agent1 = Agent(llm=OpenAIChat(), agent_name="agent1")
agent2 = Agent(llm=OpenAIChat(), agent_name="agent2")

@ -2,7 +2,7 @@ import os
from dotenv import load_dotenv
from swarms import OpenAIChat, Agent
from swarms import Agent, OpenAIChat
from swarms.tools.tool import tool
load_dotenv()

@ -1,8 +1,9 @@
import os
import multion
from dotenv import load_dotenv
from swarms.models.base_llm import AbstractLLM
from dotenv import load_dotenv
# Load environment variables
load_dotenv()

@ -6,6 +6,7 @@ from langchain.docstore import InMemoryDocstore
from langchain.embeddings import OpenAIEmbeddings
from langchain.vectorstores import FAISS
from langchain_experimental.autonomous_agents import AutoGPT
from swarms.tools.tool import BaseTool
from swarms.utils.decorators import error_decorator, timing_decorator

@ -1,9 +1,7 @@
from swarms.models.anthropic import Anthropic # noqa: E402
from swarms.models.base_embedding_model import BaseEmbeddingModel
from swarms.models.base_llm import AbstractLLM # noqa: E402
from swarms.models.base_multimodal_model import (
BaseMultiModalModel,
)
from swarms.models.base_multimodal_model import BaseMultiModalModel
# noqa: E402
from swarms.models.biogpt import BioGPT # noqa: E402
@ -15,9 +13,7 @@ from swarms.models.clipq import CLIPQ # noqa: E402
# from swarms.models.kosmos_two import Kosmos # noqa: E402
# from swarms.models.cog_agent import CogAgent # noqa: E402
## Function calling models
from swarms.models.fire_function import (
FireFunctionCaller,
)
from swarms.models.fire_function import FireFunctionCaller
from swarms.models.fuyu import Fuyu # noqa: E402
from swarms.models.gemini import Gemini # noqa: E402
from swarms.models.gigabind import Gigabind # noqa: E402
@ -25,9 +21,7 @@ from swarms.models.gpt4_vision_api import GPT4VisionAPI # noqa: E402
from swarms.models.huggingface import HuggingfaceLLM # noqa: E402
from swarms.models.idefics import Idefics # noqa: E402
from swarms.models.kosmos_two import Kosmos # noqa: E402
from swarms.models.layoutlm_document_qa import (
LayoutLMDocumentQA,
)
from swarms.models.layoutlm_document_qa import LayoutLMDocumentQA
# noqa: E402
from swarms.models.llava import LavaMultiModal # noqa: E402
@ -47,10 +41,7 @@ from swarms.models.petals import Petals # noqa: E402
from swarms.models.qwen import QwenVLMultiModal # noqa: E402
from swarms.models.roboflow_model import RoboflowMultiModal
from swarms.models.sam_supervision import SegmentAnythingMarkGenerator
from swarms.models.sampling_params import (
SamplingParams,
SamplingType,
)
from swarms.models.sampling_params import SamplingParams, SamplingType
from swarms.models.timm import TimmModel # noqa: E402
# from swarms.models.modelscope_pipeline import ModelScopePipeline
@ -67,15 +58,11 @@ from swarms.models.types import ( # noqa: E402
TextModality,
VideoModality,
)
from swarms.models.ultralytics_model import (
UltralyticsModel,
)
from swarms.models.ultralytics_model import UltralyticsModel
# noqa: E402
from swarms.models.vilt import Vilt # noqa: E402
from swarms.models.wizard_storytelling import (
WizardLLMStoryTeller,
)
from swarms.models.wizard_storytelling import WizardLLMStoryTeller
# noqa: E402
# from swarms.models.vllm import vLLM # noqa: E402

@ -2,7 +2,7 @@ from __future__ import annotations
import logging
import os
from typing import Any, Callable, Dict, List, Mapping, Optional, Union
from typing import Any, Callable, Mapping
import openai
from langchain_core.pydantic_v1 import (
@ -36,14 +36,14 @@ class AzureOpenAI(BaseOpenAI):
openai = AzureOpenAI(model_name="gpt-3.5-turbo-instruct")
"""
azure_endpoint: Union[str, None] = None
azure_endpoint: str | None = None
"""Your Azure endpoint, including the resource.
Automatically inferred from env var `AZURE_OPENAI_ENDPOINT` if not provided.
Example: `https://example-resource.azure.openai.com/`
"""
deployment_name: Union[str, None] = Field(
deployment_name: str | None = Field(
default=None, alias="azure_deployment"
)
"""A model deployment.
@ -53,11 +53,11 @@ class AzureOpenAI(BaseOpenAI):
"""
openai_api_version: str = Field(default="", alias="api_version")
"""Automatically inferred from env var `OPENAI_API_VERSION` if not provided."""
openai_api_key: Optional[SecretStr] = Field(
openai_api_key: SecretStr | None = Field(
default=None, alias="api_key"
)
"""Automatically inferred from env var `AZURE_OPENAI_API_KEY` if not provided."""
azure_ad_token: Optional[SecretStr] = None
azure_ad_token: SecretStr | None = None
"""Your Azure Active Directory token.
Automatically inferred from env var `AZURE_OPENAI_AD_TOKEN` if not provided.
@ -65,7 +65,7 @@ class AzureOpenAI(BaseOpenAI):
For more:
https://www.microsoft.com/en-us/security/business/identity-access/microsoft-entra-id.
""" # noqa: E501
azure_ad_token_provider: Union[Callable[[], str], None] = None
azure_ad_token_provider: Callable[[], str] | None = None
"""A function that returns an Azure Active Directory token.
Will be invoked on every request.
@ -78,12 +78,12 @@ class AzureOpenAI(BaseOpenAI):
"""
@classmethod
def get_lc_namespace(cls) -> List[str]:
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the langchain object."""
return ["langchain", "llms", "openai"]
@root_validator()
def validate_environment(cls, values: Dict) -> Dict:
def validate_environment(cls, values: dict) -> dict:
"""Validate that api key and python package exists in environment."""
if values["n"] < 1:
raise ValueError("n must be at least 1.")
@ -206,7 +206,7 @@ class AzureOpenAI(BaseOpenAI):
}
@property
def _invocation_params(self) -> Dict[str, Any]:
def _invocation_params(self) -> dict[str, Any]:
openai_params = {"model": self.deployment_name}
return {**openai_params, **super()._invocation_params}
@ -216,7 +216,7 @@ class AzureOpenAI(BaseOpenAI):
return "azure"
@property
def lc_attributes(self) -> Dict[str, Any]:
def lc_attributes(self) -> dict[str, Any]:
return {
"openai_api_type": self.openai_api_type,
"openai_api_version": self.openai_api_version,

@ -209,8 +209,6 @@ class CogVLMMultiModal(BaseMultiModalModel):
total_gb = total_bytes / (1 << 30)
if total_gb < 40:
pass
else:
pass
torch.cuda.empty_cache()
@ -462,7 +460,7 @@ class CogVLMMultiModal(BaseMultiModalModel):
elif role == "assistant":
if formatted_history:
if formatted_history[-1][1] != "":
assert False, (
raise AssertionError(
"the last query is answered. answer"
f" again. {formatted_history[-1][0]},"
f" {formatted_history[-1][1]},"
@ -473,9 +471,11 @@ class CogVLMMultiModal(BaseMultiModalModel):
text_content,
)
else:
assert False, "assistant reply before user"
raise AssertionError(
"assistant reply before user"
)
else:
assert False, f"unrecognized role: {role}"
raise AssertionError(f"unrecognized role: {role}")
return last_user_query, formatted_history, image_list

@ -1,8 +1,10 @@
from transformers import AutoModelForCausalLM, AutoTokenizer
import json
from swarms.models.base_llm import AbstractLLM
from typing import Any
from transformers import AutoModelForCausalLM, AutoTokenizer
from swarms.models.base_llm import AbstractLLM
class FireFunctionCaller(AbstractLLM):
"""

@ -1,4 +1,5 @@
from unittest.mock import MagicMock
from swarms.models.fire_function import FireFunctionCaller

@ -8,6 +8,7 @@ import time
import uuid
from typing import Any, Callable, Dict, List, Optional, Tuple
import yaml
from loguru import logger
from termcolor import colored
@ -31,7 +32,6 @@ from swarms.utils.video_to_frames import (
save_frames_as_images,
video_to_frames,
)
import yaml
# Utils

@ -2,9 +2,9 @@ import asyncio
from dataclasses import dataclass, field
from typing import Any, Callable, List, Optional
from swarms.structs.agent import Agent
from swarms.structs.task import Task
from swarms.utils.logger import logger
from swarms.structs.agent import Agent
@dataclass

@ -3,9 +3,9 @@ from typing import Any, Dict, List, Optional
from termcolor import colored
from swarms.structs.agent import Agent
from swarms.structs.base import BaseStructure
from swarms.structs.task import Task
from swarms.structs.agent import Agent
from swarms.utils.loguru_logger import logger

@ -1,15 +1,15 @@
import asyncio
import concurrent.futures
import re
import sys
from collections import Counter
from multiprocessing import Pool
from typing import Any, List
from swarms.structs.agent import Agent
from swarms.structs.conversation import Conversation
from loguru import logger
import sys
from swarms.structs.agent import Agent
from swarms.structs.conversation import Conversation
# Configure loguru logger with advanced settings
logger.remove()

@ -3,11 +3,10 @@ from typing import Any, Dict, List, Optional
from termcolor import colored
from swarms.structs.task import Task
# from swarms.utils.logger import logger
from swarms.structs.agent import Agent
from swarms.structs.conversation import Conversation
from swarms.structs.task import Task
from swarms.utils.loguru_logger import logger

@ -1,6 +1,7 @@
import cv2
from typing import List
import cv2
def video_to_frames(video_file: str) -> List:
"""

@ -1,5 +1,7 @@
from unittest.mock import MagicMock, patch
import pytest
from unittest.mock import patch, MagicMock
from swarms.agents.multion_agent import MultiOnAgent

@ -1,6 +1,5 @@
from unittest.mock import MagicMock
from swarms.models.fire_function import FireFunctionCaller

@ -1,6 +1,6 @@
from swarms import OpenAIChat
from swarms.structs.agent import Agent
from swarms.structs.message_pool import MessagePool
from swarms import OpenAIChat
def test_message_pool_initialization():

@ -1,5 +1,6 @@
import pypdf
import pytest
from swarms.utils import pdf_to_text

Loading…
Cancel
Save