merging branch local two edges

This commit is contained in:
cristhianzl 2024-06-17 11:23:21 -03:00
commit 9ad10b33f2
17 changed files with 227 additions and 500 deletions

View file

@ -1,4 +1,3 @@
from typing import Optional
from langchain_anthropic.chat_models import ChatAnthropic
from pydantic.v1 import SecretStr

View file

@ -1,4 +1,4 @@
from typing import Any, Dict, Optional
from typing import Optional
from langchain_community.chat_models.litellm import ChatLiteLLM, ChatLiteLLMException
from langflow.base.constants import STREAM_INFO_TEXT
@ -177,4 +177,4 @@ class ChatLiteLLMModelComponent(LCModelComponent):
)
return output

View file

@ -1,4 +1,3 @@
from typing import Optional
from langchain_groq import ChatGroq
from langflow.base.models.groq_constants import MODEL_NAMES
@ -103,4 +102,4 @@ class GroqModel(LCModelComponent):
streaming=stream,
)
return output
return output

View file

@ -1,4 +1,3 @@
from typing import Optional
from langchain_community.chat_models.huggingface import ChatHuggingFace
from langchain_community.llms.huggingface_endpoint import HuggingFaceEndpoint
@ -65,4 +64,4 @@ class HuggingFaceEndpointsComponent(LCModelComponent):
raise ValueError("Could not connect to HuggingFace Endpoints API.") from e
output = ChatHuggingFace(llm=llm)
return output
return output

View file

@ -1,4 +1,3 @@
from typing import Any, Dict, List, Optional
from langchain_community.chat_models import ChatOllama
from langflow.base.constants import STREAM_INFO_TEXT
@ -226,4 +225,4 @@ class ChatOllamaComponent(LCModelComponent):
except Exception as e:
raise ValueError("Could not initialize Ollama LLM.") from e
return output
return output

View file

@ -21,7 +21,6 @@ from langflow.type_extraction.type_extraction import (
extract_union_types_from_generic_alias,
)
from langflow.utils import validate
from pydantic import BaseModel
if TYPE_CHECKING:
from langflow.graph.graph.base import Graph

View file

@ -13,7 +13,7 @@ from langflow.graph.utils import UnbuiltObject, UnbuiltResult
from langflow.interface.initialize import loading
from langflow.interface.listing import lazy_load_dict
from langflow.schema.artifact import ArtifactType
from langflow.schema.schema import INPUT_FIELD_NAME, Log, build_logs
from langflow.schema.schema import INPUT_FIELD_NAME, Log
from langflow.services.deps import get_storage_service
from langflow.services.monitor.utils import log_transaction
from langflow.utils.constants import DIRECT_TYPES

View file

@ -117,51 +117,3 @@ def set_langchain_cache(settings):
logger.warning(f"Could not import {cache_type}. ")
else:
logger.info("No LLM cache set.")
def build_template_from_class(name: str, type_to_cls_dict: Dict, add_function: bool = False):
classes = [item.__name__ for item in type_to_cls_dict.values()]
# Raise error if name is not in chains
if name not in classes:
raise ValueError(f"{name} not found.")
for _type, v in type_to_cls_dict.items():
if v.__name__ == name:
_class = v
# Get the docstring
docs = parse(_class.__doc__)
variables = {"_type": _type}
if "__fields__" in _class.__dict__:
for class_field_items, value in _class.__fields__.items():
if class_field_items in ["callback_manager"]:
continue
variables[class_field_items] = {}
for name_, value_ in value.__repr_args__():
if name_ == "default_factory":
try:
variables[class_field_items]["default"] = get_default_factory(
module=_class.__base__.__module__,
function=value_,
)
except Exception:
variables[class_field_items]["default"] = None
elif name_ not in ["name"]:
variables[class_field_items][name_] = value_
variables[class_field_items]["placeholder"] = (
docs.params[class_field_items] if class_field_items in docs.params else ""
)
base_classes = get_base_classes(_class)
# Adding function to base classes to allow
# the output to be a function
if add_function:
base_classes.append("Callable")
return {
"template": format_dict(variables, name),
"description": docs.short_description or "",
"base_classes": base_classes,
}

View file

@ -1,4 +1,4 @@
from typing import Any, Literal
from typing import Literal
from typing_extensions import TypedDict