Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Pass the OpenAI API Key to Crew() #4555

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/backend/base/langflow/components/crewai/hierarchical_crew.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

from crewai import Crew, Process

from langflow.base.agents.crewai.crew import BaseCrewComponent
from langflow.io import HandleInput
from langflow.io import HandleInput, SecretStrInput


class HierarchicalCrewComponent(BaseCrewComponent):
Expand All @@ -18,10 +20,21 @@ class HierarchicalCrewComponent(BaseCrewComponent):
HandleInput(name="tasks", display_name="Tasks", input_types=["HierarchicalTask"], is_list=True),
HandleInput(name="manager_llm", display_name="Manager LLM", input_types=["LanguageModel"], required=False),
HandleInput(name="manager_agent", display_name="Manager Agent", input_types=["Agent"], required=False),
SecretStrInput(
name="openai_api_key",
display_name="OpenAI API Key",
info="The OpenAI API Key to use for the OpenAI model.",
value="OPENAI_API_KEY",
),
]

def build_crew(self) -> Crew:
tasks, agents = self.get_tasks_and_agents()

# Set the OpenAI API Key
if self.openai_api_key:
os.environ["OPENAI_API_KEY"] = self.openai_api_key

return Crew(
agents=agents,
tasks=tasks,
Expand Down
Loading