diff --git a/swarms/memory/embed.py b/swarms/memory/embed.py new file mode 100644 index 00000000..43f48a9a --- /dev/null +++ b/swarms/memory/embed.py @@ -0,0 +1,11 @@ +# This file contains the function that embeds the input into a vector +from chromadb import EmbeddingFunction + + +def openai_embed(self, input, api_key, model_name): + openai = EmbeddingFunction.OpenAIEmbeddingFunction( + api_key=api_key, + model_name=model_name + ) + embedding = openai(input) + return embedding \ No newline at end of file diff --git a/swarms/tools/stt.py b/swarms/tools/stt.py index c442dd03..cf260be0 100644 --- a/swarms/tools/stt.py +++ b/swarms/tools/stt.py @@ -1,9 +1,10 @@ -#speech to text +#speech to text tool import os from pydub import AudioSegment from pytube import YouTube import whisperx +import subprocess class SpeechToText: def __init__( @@ -30,6 +31,13 @@ class SpeechToText: self.compute_type = compute_type self.hf_api_key = hf_api_key + def install(self): + subprocess.run(["pip", "install", "whisperx"]) + subprocess.run(["pip", "install", "pytube"]) + subprocess.run(["pip", "install", "pydub"]) + + + def download_youtube_video(self): audio_file = f'video.{self.audio_format}' diff --git a/swarms/workers/worker_ultra_node.py b/swarms/workers/worker_ultra_node.py index c9331bba..143009bf 100644 --- a/swarms/workers/worker_ultra_node.py +++ b/swarms/workers/worker_ultra_node.py @@ -1,23 +1,29 @@ +import logging import os import re -import logging from pathlib import Path from typing import Dict, List from swarms.agents.utils.agent_creator import AgentCreator -from swarms.utils.main import BaseHandler, FileHandler, FileType -from swarms.tools.main import ExitConversation, RequestsGet, CodeEditor, Terminal -from swarms.utils.main import CsvToDataframe -from swarms.tools.main import BaseToolSet -from swarms.utils.main import StaticUploader +from swarms.tools.main import ( + BaseToolSet, + CodeEditor, + ExitConversation, + RequestsGet, + Terminal, +) +from swarms.utils.main import ( + BaseHandler, + CsvToDataframe, + FileHandler, + FileType, + StaticUploader, +) logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') - BASE_DIR = Path(__file__).resolve().parent.parent - # Check if "PLAYGROUND_DIR" environment variable exists, if not, set a default value playground = os.environ.get("PLAYGROUND_DIR", './playground') - # Ensure the path exists before changing the directory os.makedirs(BASE_DIR / playground, exist_ok=True) @@ -45,8 +51,14 @@ class WorkerUltraNode: if os.environ.get("USE_GPU", False): import torch - from swarms.tools.main import ImageCaptioning - from swarms.tools.main import ImageEditing, InstructPix2Pix, Text2Image, VisualQuestionAnswering + + from swarms.tools.main import ( + ImageCaptioning, + ImageEditing, + InstructPix2Pix, + Text2Image, + VisualQuestionAnswering, + ) if torch.cuda.is_available(): toolsets.extend(