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

Format code and update langflow version #1922

Merged
merged 9 commits into from
May 20, 2024
756 changes: 365 additions & 391 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow"
version = "1.0.0a33"
version = "1.0.0a34"
description = "A Python package with a built-in web application"
authors = ["Langflow <contact@langflow.org>"]
maintainers = [
Expand Down
1 change: 0 additions & 1 deletion src/backend/base/langflow/base/io/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def store_message(
sender: Optional[str] = None,
sender_name: Optional[str] = None,
) -> list[Record]:

records = store_message(
message,
session_id=session_id,
Expand Down
2 changes: 0 additions & 2 deletions src/backend/base/langflow/base/memory/memory.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import Optional

from langflow.field_typing import Text
from langflow.helpers.record import records_to_text
from langflow.interface.custom.custom_component import CustomComponent
from langflow.schema.schema import Record

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import List, Optional
from pydantic.v1 import SecretStr

from langchain_mistralai.embeddings import MistralAIEmbeddings
from langflow.interface.custom.custom_component import CustomComponent
from langflow.field_typing import Embeddings, NestedDict
from langflow.field_typing import Embeddings


class MistralAIEmbeddingsComponent(CustomComponent):
display_name = "MistralAI Embeddings"
Expand Down Expand Up @@ -37,11 +37,7 @@ def build_config(self):
"advanced": True,
"value": 120,
},
"endpoint": {
"display_name": "API Endpoint",
"advanced": True,
"value": "https://api.mistral.ai/v1/"
}
"endpoint": {"display_name": "API Endpoint", "advanced": True, "value": "https://api.mistral.ai/v1/"},
}

def build(
Expand All @@ -51,7 +47,7 @@ def build(
max_concurrent_requests: int = 64,
max_retries: int = 5,
timeout: int = 120,
endpoint: str = "https://api.mistral.ai/v1/"
endpoint: str = "https://api.mistral.ai/v1/",
) -> Embeddings:
if mistral_api_key:
api_key = SecretStr(mistral_api_key)
Expand All @@ -64,6 +60,5 @@ def build(
endpoint=endpoint,
max_concurrent_requests=max_concurrent_requests,
max_retries=max_retries,
timeout=timeout
timeout=timeout,
)

5 changes: 3 additions & 2 deletions src/backend/base/langflow/components/experimental/Pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
from langflow.schema import Record
from langflow.field_typing import Text


class PassComponent(CustomComponent):
display_name = "Pass"
description = "A pass-through component that forwards the second input while ignoring the first, used for controlling workflow direction."
field_order = ["ignored_input", "forwarded_input"]

def build_config(self) -> dict:
return {
"ignored_input": {
Expand All @@ -19,7 +20,7 @@ def build_config(self) -> dict:
"display_name": "Input",
"info": "This input is forwarded by the component.",
"input_types": ["Text", "Record"],
}
},
}

def build(self, ignored_input: Text, forwarded_input: Text) -> Union[Text, Record]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def build(
session_id: Optional[str] = None,
message: str = "",
) -> List[Record]:

store_message(
sender=sender,
sender_name=sender_name,
Expand Down
17 changes: 4 additions & 13 deletions src/backend/base/langflow/components/experimental/TextOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from langflow.schema import Record
from langflow.field_typing import Text


class TextOperatorComponent(CustomComponent):
display_name = "Text Operator"
description = "Compares two text inputs based on a specified condition such as equality or inequality, with optional case sensitivity."
Expand All @@ -21,14 +22,7 @@ def build_config(self) -> dict:
"operator": {
"display_name": "Operator",
"info": "The operator to apply for comparing the texts.",
"options": [
"equals",
"not equals",
"contains",
"starts with",
"ends with",
"exists"
],
"options": ["equals", "not equals", "contains", "starts with", "ends with", "exists"],
},
"case_sensitive": {
"display_name": "Case Sensitive",
Expand All @@ -51,11 +45,8 @@ def build(
case_sensitive: bool = False,
true_output: Optional[Text] = "",
) -> Union[Text, Record]:

if not input_text or not match_text:
raise ValueError(
"Both 'input_text' and 'match_text' must be provided and non-empty."
)
raise ValueError("Both 'input_text' and 'match_text' must be provided and non-empty.")

if not case_sensitive:
input_text = input_text.lower()
Expand All @@ -82,4 +73,4 @@ def build(
self.status = "Comparison failed, stopping execution."
self.stop()

return output_record
return output_record
2 changes: 1 addition & 1 deletion src/backend/base/langflow/graph/graph/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,9 +715,9 @@ async def build_vertex(
lock: asyncio.Lock,
set_cache_coro: Callable[["Graph", asyncio.Lock], Coroutine],
vertex_id: str,
fallback_to_env_vars: bool,
inputs_dict: Optional[Dict[str, str]] = None,
user_id: Optional[str] = None,
fallback_to_env_vars: bool = False,
):
"""
Builds a vertex in the graph.
Expand Down
6 changes: 5 additions & 1 deletion src/backend/base/langflow/graph/vertex/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,11 @@ def _build_params(self):
params[field_name] = full_path
elif field.get("required"):
field_display_name = field.get("display_name")
raise ValueError(f"File path not found for {field_display_name} in component {self.display_name}")
logger.warning(
f"File path not found for {field_display_name} in component {self.display_name}. Setting to None."
)
params[field_name] = None

elif field.get("type") in DIRECT_TYPES and params.get(field_name) is None:
val = field.get("value")
if field.get("type") == "code":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from langchain_community.vectorstores import (
FAISS,
Chroma,
ElasticsearchStore,
MongoDBAtlasVectorSearch,
Pinecone,
Qdrant,
Expand Down
1 change: 0 additions & 1 deletion src/backend/base/langflow/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def store_message(
sender: Optional[str] = None,
sender_name: Optional[str] = None,
) -> list[Record]:

if not message:
warnings.warn("No message provided.")
return []
Expand Down
3 changes: 2 additions & 1 deletion src/backend/base/langflow/processing/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def run_flow_from_json(
env_file: Optional[str] = None,
cache: Optional[str] = None,
disable_logs: Optional[bool] = True,
fallback_to_env_vars: Optional[bool] = False,
fallback_to_env_vars: bool = False,
) -> List[RunOutputs]:
"""
Run a flow from a JSON file or dictionary.
Expand All @@ -99,6 +99,7 @@ def run_flow_from_json(
env_file (Optional[str], optional): The environment file to load. Defaults to None.
cache (Optional[str], optional): The cache directory to use. Defaults to None.
disable_logs (Optional[bool], optional): Whether to disable logs. Defaults to True.
fallback_to_env_vars (bool, optional): Whether Global Variables should fallback to environment variables if not found. Defaults to False.

Returns:
List[RunOutputs]: A list of RunOutputs objects representing the results of running the flow.
Expand Down
1 change: 0 additions & 1 deletion src/backend/base/langflow/schema/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from langchain_core.documents import Document
from langchain_core.messages import AIMessage, BaseMessage, HumanMessage
from pydantic import BaseModel, model_validator
from langchain_core.messages import HumanMessage, AIMessage


class Record(BaseModel):
Expand Down
36 changes: 20 additions & 16 deletions src/backend/base/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/backend/base/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow-base"
version = "0.0.44"
version = "0.0.45"
description = "A Python package with a built-in web application"
authors = ["Langflow <contact@langflow.org>"]
maintainers = [
Expand Down
Loading
Loading