Repository: VinciGit00/Scrapegraph-ai
File: scrapegraphai/graphs/abstract_graph.py (Python)

Code before:
                self.model_token = 8192
            return ErnieBotChat(llm_params)

        elif "oneapi" in llm_params["model"]:

            # take the model after the last dash
            llm_params["model"] = llm_params["model"].split("/")[-1]
            try:
                self.model_token = models_tokens["oneapi"][llm_params["model"]]
            except KeyError as exc:
                raise KeyError("Model not supported") from exc
            return OneApi(llm_params)

        elif "nvidia" in llm_params["model"]:

            try:
                self.model_token = models_tokens["nvidia"][llm_params["model"].split("/")[-1]]
                llm_params["model"] = "/".join(llm_params["model"].split("/")[1:])
            except KeyError as exc:
                raise KeyError("Model not supported") from exc
            return ChatNVIDIA(llm_params)
        else:
            model_name = llm_params["model"].split("/")[-1]
            return handle_model(model_name, llm_params["model"], model_name)

        raise ValueError("Model provided by the configuration not supported")


    def get_state(self, key=None) -> dict:
        """ ""
        Get the final state of the graph.

        Args:
            key (str, optional): The key of the final state to retrieve.

        Returns:
            dict: The final state of the graph.
        """

        if key is not None:
            return self.final_state[key]
        return self.final_state

    def append_node(self, node):
        """
        Add a node to the graph.

        Args:
            node (BaseNode): The node to add to the graph.
        """


Review comment (suggestion):
Unreachable code, because the `if/elif/else` block causes it to be skipped in all cases. The old version constisted only of `if` statements because there would be no fall-through in any case

Code after:
                return DeepSeek(llm_params)

            elif "ernie" in llm_params["model"]:
                try:
                    self.model_token = models_tokens["ernie"][llm_params["model"]]
                except KeyError:
                    print("model not found, using default token size (8192)")
                    self.model_token = 8192
                return ErnieBotChat(llm_params)

            elif "oneapi" in llm_params["model"]:
                # take the model after the last dash
                llm_params["model"] = llm_params["model"].split("/")[-1]
                try:
                    self.model_token = models_tokens["oneapi"][llm_params["model"]]
                except KeyError:
                    raise KeyError("Model not supported")
                return OneApi(llm_params)

            elif "nvidia" in llm_params["model"]:
                try:
                    self.model_token = models_tokens["nvidia"][llm_params["model"].split("/")[-1]]
                    llm_params["model"] = "/".join(llm_params["model"].split("/")[1:])
                except KeyError:
                    raise KeyError("Model not supported")
                return ChatNVIDIA(llm_params)

            else:
                model_name = llm_params["model"].split("/")[-1]
                return handle_model(model_name, llm_params["model"], model_name)

        except KeyError as e:
            print(f"Model not supported: {e}")


    def get_state(self, key=None) -> dict:
        """ ""
        Get the final state of the graph.

        Args:
            key (str, optional): The key of the final state to retrieve.

        Returns:
            dict: The final state of the graph.
        """

        if key is not None:
            return self.final_state[key]
        return self.final_state

    def append_node(self, node):