fix unnecessary deps

This commit is contained in:
Brandon Hancock
2024-10-17 10:00:04 -04:00
parent b55fc40c83
commit a5f70d2307

View File

@@ -2,9 +2,6 @@ import importlib.metadata
import os import os
import shutil import shutil
import sys import sys
from crewai.cli.authentication.utils import TokenManager
from crewai.cli.constants import ENV_VARS
from functools import reduce from functools import reduce
from typing import Any, Dict, List from typing import Any, Dict, List
@@ -12,6 +9,7 @@ import click
from rich.console import Console from rich.console import Console
from crewai.cli.authentication.utils import TokenManager from crewai.cli.authentication.utils import TokenManager
from crewai.cli.constants import ENV_VARS
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
import tomllib import tomllib
@@ -220,11 +218,12 @@ def load_env_vars(folder_path):
if env_file_path.exists(): if env_file_path.exists():
with open(env_file_path, "r") as file: with open(env_file_path, "r") as file:
for line in file: for line in file:
key, _, value = line.strip().partition('=') key, _, value = line.strip().partition("=")
if key and value: if key and value:
env_vars[key] = value env_vars[key] = value
return env_vars return env_vars
def update_env_vars(env_vars, provider, model): def update_env_vars(env_vars, provider, model):
""" """
Updates environment variables with the API key for the selected provider and model. Updates environment variables with the API key for the selected provider and model.
@@ -237,10 +236,15 @@ def update_env_vars(env_vars, provider, model):
Returns: Returns:
- None - None
""" """
api_key_var = ENV_VARS.get(provider, [click.prompt( api_key_var = ENV_VARS.get(
provider,
[
click.prompt(
f"Enter the environment variable name for your {provider.capitalize()} API key", f"Enter the environment variable name for your {provider.capitalize()} API key",
type=str type=str,
)])[0] )
],
)[0]
if api_key_var not in env_vars: if api_key_var not in env_vars:
try: try:
@@ -253,10 +257,11 @@ def update_env_vars(env_vars, provider, model):
else: else:
click.secho(f"API key already exists for {provider.capitalize()}.", fg="yellow") click.secho(f"API key already exists for {provider.capitalize()}.", fg="yellow")
env_vars['MODEL'] = model env_vars["MODEL"] = model
click.secho(f"Selected model: {model}", fg="green") click.secho(f"Selected model: {model}", fg="green")
return env_vars return env_vars
def write_env_file(folder_path, env_vars): def write_env_file(folder_path, env_vars):
""" """
Writes environment variables to a .env file in the specified folder. Writes environment variables to a .env file in the specified folder.