Skip to content

Commit

Permalink
Merge pull request #806 from Levyathanus/pre/beta
Browse files Browse the repository at this point in the history
fix: try to infer possible provider from the model name, resolves #805
  • Loading branch information
VinciGit00 authored Nov 18, 2024
2 parents 777a685 + d2d0312 commit 8fd7b24
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scrapegraphai/graphs/abstract_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,18 @@ def _create_llm(self, llm_config: dict) -> object:
"ollama", "oneapi", "nvidia", "groq", "anthropic", "bedrock", "mistralai",
"hugging_face", "deepseek", "ernie", "fireworks", "togetherai"}

split_model_provider = llm_params["model"].split("/", 1)
llm_params["model_provider"] = split_model_provider[0]
llm_params["model"] = split_model_provider[1]
if '/' in llm_params["model"]:
split_model_provider = llm_params["model"].split("/", 1)
llm_params["model_provider"] = split_model_provider[0]
llm_params["model"] = split_model_provider[1]
else:
possible_providers = [provider for provider, models_d in models_tokens.items() if llm_params["model"] in models_d]
if len(possible_providers) <= 0:
raise ValueError(f"""Provider {llm_params['model_provider']} is not supported.
If possible, try to use a model instance instead.""")
llm_params["model_provider"] = possible_providers[0]
print((f"Found providers {possible_providers} for model {llm_params['model']}, using {llm_params['model_provider']}.\n"
"If it was not intended please specify the model provider in the graph configuration"))

if llm_params["model_provider"] not in known_providers:
raise ValueError(f"""Provider {llm_params['model_provider']} is not supported.
Expand Down

0 comments on commit 8fd7b24

Please sign in to comment.