diff --git a/swarms/tools/stt.py b/swarms/tools/stt.py index 2bc46c0d..cfe3e656 100644 --- a/swarms/tools/stt.py +++ b/swarms/tools/stt.py @@ -98,8 +98,9 @@ class SpeechToText: # 2. Align Whisper output 🔍 model_a, metadata = whisperx.load_align_model( - language_code=result["language"], device=device + language_code=result["language"], device=self.device ) + result = whisperx.align( result["segments"], model_a, diff --git a/swarms/tools/tool_registry.py b/swarms/tools/tool_registry.py index 42f3b556..5aa544e9 100644 --- a/swarms/tools/tool_registry.py +++ b/swarms/tools/tool_registry.py @@ -1,7 +1,7 @@ -from .tool import Tool +from swarms.tools.tool import tool from typing import Dict, Callable, Any, List -ToolBuilder = Callable[[Any], Tool] +ToolBuilder = Callable[[Any], tool] FuncToolBuilder = Callable[[], ToolBuilder] @@ -13,9 +13,9 @@ class ToolsRegistry: print(f"will register {tool_name}") self.tools[tool_name] = tool - def build(self, tool_name, config) -> Tool: + def build(self, tool_name, config): ret = self.tools[tool_name]()(config) - if isinstance(ret, Tool): + if isinstance(ret, tool): return ret raise ValueError( "Tool builder {} did not return a Tool instance".format(tool_name) @@ -36,7 +36,7 @@ def register(tool_name): return decorator -def build_tool(tool_name: str, config: Any) -> Tool: +def build_tool(tool_name: str, config: Any) -> tool: print(f"will build {tool_name}") return tools_registry.build(tool_name, config) diff --git a/swarms/workers/worker.py b/swarms/workers/worker.py index 6ad9d930..c3bda43b 100644 --- a/swarms/workers/worker.py +++ b/swarms/workers/worker.py @@ -30,7 +30,7 @@ class Worker: Parameters: - `model_name` (str): The name of the language model to be used (default: "gpt-4"). - - `openai_api_key` (str): The OpenAI API key (optional). + - `openai_api_key` (str): The OpenvAI API key (optional). - `ai_name` (str): The name of the AI worker. - `ai_role` (str): The role of the AI worker. - `external_tools` (list): List of external tools (optional). @@ -142,8 +142,9 @@ class Worker: """ Set up memory for the worker. """ + openai_api_key = os.getenv("OPENAI_API_KEY") or self.openai_api_key try: - embeddings_model = OpenAIEmbeddings(openai_api_key=self.openai_api_key) + embeddings_model = OpenAIEmbeddings(openai_api_key=openai_api_key) embedding_size = 1536 index = faiss.IndexFlatL2(embedding_size)