openai key error

pull/64/head
Kye 1 year ago
parent 3c3d05fa1c
commit fb1aaf5700

@ -98,8 +98,9 @@ class SpeechToText:
# 2. Align Whisper output 🔍 # 2. Align Whisper output 🔍
model_a, metadata = whisperx.load_align_model( model_a, metadata = whisperx.load_align_model(
language_code=result["language"], device=device language_code=result["language"], device=self.device
) )
result = whisperx.align( result = whisperx.align(
result["segments"], result["segments"],
model_a, model_a,

@ -1,7 +1,7 @@
from .tool import Tool from swarms.tools.tool import tool
from typing import Dict, Callable, Any, List from typing import Dict, Callable, Any, List
ToolBuilder = Callable[[Any], Tool] ToolBuilder = Callable[[Any], tool]
FuncToolBuilder = Callable[[], ToolBuilder] FuncToolBuilder = Callable[[], ToolBuilder]
@ -13,9 +13,9 @@ class ToolsRegistry:
print(f"will register {tool_name}") print(f"will register {tool_name}")
self.tools[tool_name] = tool self.tools[tool_name] = tool
def build(self, tool_name, config) -> Tool: def build(self, tool_name, config):
ret = self.tools[tool_name]()(config) ret = self.tools[tool_name]()(config)
if isinstance(ret, Tool): if isinstance(ret, tool):
return ret return ret
raise ValueError( raise ValueError(
"Tool builder {} did not return a Tool instance".format(tool_name) "Tool builder {} did not return a Tool instance".format(tool_name)
@ -36,7 +36,7 @@ def register(tool_name):
return decorator 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}") print(f"will build {tool_name}")
return tools_registry.build(tool_name, config) return tools_registry.build(tool_name, config)

@ -30,7 +30,7 @@ class Worker:
Parameters: Parameters:
- `model_name` (str): The name of the language model to be used (default: "gpt-4"). - `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_name` (str): The name of the AI worker.
- `ai_role` (str): The role of the AI worker. - `ai_role` (str): The role of the AI worker.
- `external_tools` (list): List of external tools (optional). - `external_tools` (list): List of external tools (optional).
@ -142,8 +142,9 @@ class Worker:
""" """
Set up memory for the worker. Set up memory for the worker.
""" """
openai_api_key = os.getenv("OPENAI_API_KEY") or self.openai_api_key
try: try:
embeddings_model = OpenAIEmbeddings(openai_api_key=self.openai_api_key) embeddings_model = OpenAIEmbeddings(openai_api_key=openai_api_key)
embedding_size = 1536 embedding_size = 1536
index = faiss.IndexFlatL2(embedding_size) index = faiss.IndexFlatL2(embedding_size)

Loading…
Cancel
Save