diff --git a/.github/workflows/quality.yml b/.github/workflows/quality.yml new file mode 100644 index 00000000..82e56088 --- /dev/null +++ b/.github/workflows/quality.yml @@ -0,0 +1,23 @@ +name: Quality + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + lint: + runs-on: ubuntu-latest + strategy: + fail-fast: false + steps: + - name: Checkout actions + uses: actions/checkout@v1 + with: + fetch-depth: 0 + - name: Init environment + uses: ./.github/actions/init-environment + - name: Run linter + run: | + pylint `git diff --name-only --diff-filter=d origin/main HEAD | grep -E '\.py$' | tr '\n' ' '` \ No newline at end of file diff --git a/.gitignore b/.gitignore index ceed49ba..983ba123 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ swarms/agents/.DS_Store _build +.DS_STORE \ No newline at end of file diff --git a/swarms/workers/multi_modal_workers/multi_modal_agent.py b/swarms/workers/multi_modal_workers/multi_modal_agent.py index 7fbdc345..bd989422 100644 --- a/swarms/workers/multi_modal_workers/multi_modal_agent.py +++ b/swarms/workers/multi_modal_workers/multi_modal_agent.py @@ -1,48 +1,58 @@ # coding: utf-8 +import argparse +import inspect +import math import os -import gradio as gr import random -import torch -import cv2 import re import uuid -from PIL import Image, ImageDraw, ImageOps, ImageFont -import math -import numpy as np -import argparse -import inspect -from transformers import pipeline, BlipProcessor, BlipForConditionalGeneration, BlipForQuestionAnswering -from diffusers import StableDiffusionPipeline, StableDiffusionInpaintPipeline, StableDiffusionInstructPix2PixPipeline -from diffusers import EulerAncestralDiscreteScheduler -from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler +import cv2 +import gradio as gr +import matplotlib.pyplot as plt +import numpy as np +import torch +import wget +from controlnet_aux import HEDdetector, MLSDdetector, OpenposeDetector +from diffusers import ( + ControlNetModel, + EulerAncestralDiscreteScheduler, + StableDiffusionControlNetPipeline, + StableDiffusionInpaintPipeline, + StableDiffusionInstructPix2PixPipeline, + StableDiffusionPipeline, + UniPCMultistepScheduler, +) from diffusers.pipelines.stable_diffusion import StableDiffusionSafetyChecker - -from controlnet_aux import OpenposeDetector, MLSDdetector, HEDdetector - from langchain.agents.initialize import initialize_agent from langchain.agents.tools import Tool from langchain.chains.conversation.memory import ConversationBufferMemory from langchain.llms.openai import OpenAI +from PIL import Image, ImageDraw, ImageFont, ImageOps +from transformers import ( + BlipForConditionalGeneration, + BlipForQuestionAnswering, + BlipProcessor, + pipeline, +) # Grounding DINO # import groundingdino.datasets.transforms as T from swarms.workers.models import ( Compose, Normalize, + RandomResize, + SLConfig, ToTensor, - RandomResize + build_model, + clean_state_dict, + get_phrases_from_posmap, +) +from swarms.workers.models.segment_anything import ( + SamAutomaticMaskGenerator, + SamPredictor, + build_sam, ) - -from swarms.workers.models import build_model -from swarms.workers.models import SLConfig -from swarms.workers.models import clean_state_dict, get_phrases_from_posmap - -from swarms.workers.models.segment_anything import build_sam, SamPredictor, SamAutomaticMaskGenerator -import cv2 -import numpy as np -import matplotlib.pyplot as plt -import wget VISUAL_AGENT_PREFIX = """Worker Multi-Modal Agent is designed to be able to assist with a wide range of text and visual related tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. Worker Multi-Modal Agent is able to generate human-like text based on the input it receives, allowing it to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand. diff --git a/swarms/workers/worker_agent_ultra.py b/swarms/workers/worker_agent_ultra.py index 26dede42..cb355145 100644 --- a/swarms/workers/worker_agent_ultra.py +++ b/swarms/workers/worker_agent_ultra.py @@ -1,23 +1,28 @@ -import os import logging +import os +from typing import Dict, List +from langchain.memory.chat_message_histories import FileChatMessageHistory from swarms.agents.tools.agent_tools import * -from typing import List, Dict -from langchain.memory.chat_message_histories import FileChatMessageHistory -import logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') -from typing import List, Dict +from typing import Dict, List + from langchain.memory.chat_message_histories import FileChatMessageHistory -from swarms.utils.main import BaseHandler, FileType -from swarms.agents.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal -from swarms.utils.main import CsvToDataframe -from swarms.agents.tools.main import BaseToolSet + +from swarms.agents.tools.main import ( + BaseToolSet, + CodeEditor, + ExitConversation, + RequestsGet, + Terminal, +) +from swarms.utils.main import BaseHandler, CsvToDataframe, FileType class WorkerUltraNode: @@ -105,8 +110,14 @@ class WorkerUltraNodeInitializer: if os.environ.get("USE_GPU", False): import torch - from swarms.agents.tools.main import ImageCaptioning - from swarms.agents.tools.main import ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering + + from swarms.agents.tools.main import ( + ImageCaptioning, + ImageEditing, + InstructPix2Pix, + Text2Image, + VisualQuestionAnswering, + ) if torch.cuda.is_available(): toolsets.extend(