Skip to content

Commit

Permalink
Merge branch 'main' into fix/saved_components_disappearing
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaseduoli authored Dec 20, 2024
2 parents de5aa61 + 4b0c42e commit 5b60795
Show file tree
Hide file tree
Showing 28 changed files with 1,084 additions and 728 deletions.
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ dependencies = [
"yfinance==0.2.50",
"wolframalpha==5.1.3",
"astra-assistants[tools]~=2.2.6",
"composio-langchain==0.5.42",
"composio-langchain==0.6.3",
"composio-core==0.6.3",
"spider-client==0.1.24",
"nltk==3.9.1",
"lark==1.2.2",
Expand Down Expand Up @@ -180,7 +181,7 @@ dev-dependencies = [
"asgi-lifespan>=2.1.0",
"pytest-github-actions-annotate-failures>=0.2.0",
"pytest-codspeed>=3.0.0",
"blockbuster>=1.5.2,<1.6",
"blockbuster>=1.5.5,<1.6",
"types-aiofiles>=24.1.0.20240626",
"codeflash>=0.8.4",
]
Expand Down
10 changes: 1 addition & 9 deletions src/backend/base/langflow/base/agents/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ class InputDict(TypedDict):


def _build_agent_input_text_content(agent_input_dict: InputDict) -> str:
chat_history = agent_input_dict.get("chat_history", [])
messages = [
f"**{message.type.upper()}**: {message.content}"
for message in chat_history
if isinstance(message, BaseMessage) and message.content
]
final_input = agent_input_dict.get("input", "")
if messages and final_input not in messages[-1]:
messages.append(f"**HUMAN**: {final_input}")
return " \n".join(messages)
return f"**Input**: {final_input}"


def _calculate_duration(start_time: float) -> int:
Expand Down
20 changes: 13 additions & 7 deletions src/backend/base/langflow/components/composio/composio_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from composio_langchain import Action, App, ComposioToolSet
from langchain_core.tools import Tool
from loguru import logger
from typing_extensions import override

# Local imports
from langflow.base.langchain_utilities.model import LCToolComponent
Expand All @@ -30,16 +29,17 @@ class ComposioAPIComponent(LCToolComponent):
name="api_key",
display_name="Composio API Key",
required=True,
# refresh_button=True,
info="Refer to https://docs.composio.dev/faq/api_key/api_key",
real_time_refresh=True,
),
DropdownInput(
name="app_names",
display_name="App Name",
options=list(App.__annotations__),
options=[str(app).replace("App.", "") for app in App.all()],
value="",
info="The app name to use. Please refresh after selecting app name",
refresh_button=True,
required=True,
),
# Authentication-related inputs (initially hidden)
SecretStrInput(
Expand All @@ -49,6 +49,7 @@ class ComposioAPIComponent(LCToolComponent):
dynamic=True,
show=False,
info="Credentials for app authentication (API Key, Password, etc)",
load_from_db=False,
),
MessageTextInput(
name="username",
Expand Down Expand Up @@ -220,19 +221,24 @@ def _get_normalized_app_name(self) -> str:
"""
return self.app_names.replace(" ✅", "").replace("_connected", "")

@override
def update_build_config(self, build_config: dict, field_value: Any, field_name: str | None = None) -> dict:
def update_build_config(self, build_config: dict, field_value: Any, field_name: str | None = None) -> dict: # noqa: ARG002
# First, ensure all dynamic fields are hidden by default
dynamic_fields = ["app_credentials", "username", "auth_link", "auth_status", "action_names"]
for field in dynamic_fields:
if field in build_config:
if build_config[field]["value"] is None or build_config[field]["value"] == "":
build_config[field]["show"] = False
build_config[field]["advanced"] = True # Hide from main view
build_config[field]["advanced"] = True
build_config[field]["load_from_db"] = False
else:
build_config[field]["show"] = True
build_config[field]["advanced"] = False

if field_name == "app_names" and (not hasattr(self, "app_names") or not self.app_names):
build_config["auth_status"]["show"] = True
build_config["auth_status"]["value"] = "Please select an app first"
return build_config

if field_name == "app_names" and hasattr(self, "api_key") and self.api_key != "":
# app_name = self._get_normalized_app_name()
app_name = self.app_names
Expand Down Expand Up @@ -285,7 +291,7 @@ def update_build_config(self, build_config: dict, field_value: Any, field_name:

# Update action names if connected
if build_config["auth_status"]["value"] == "✅":
all_action_names = list(Action.__annotations__)
all_action_names = [str(action).replace("Action.", "") for action in Action.all()]
app_action_names = [
action_name
for action_name in all_action_names
Expand Down
4 changes: 2 additions & 2 deletions src/backend/base/langflow/components/helpers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from .id_generator import IDGeneratorComponent
from .memory import MemoryComponent
from .output_parser import OutputParserComponent
from .store_message import StoreMessageComponent
from .store_message import MessageStoreComponent
from .structured_output import StructuredOutputComponent

__all__ = [
"CreateListComponent",
"CurrentDateComponent",
"IDGeneratorComponent",
"MemoryComponent",
"MessageStoreComponent",
"OutputParserComponent",
"StoreMessageComponent",
"StructuredOutputComponent",
]
8 changes: 4 additions & 4 deletions src/backend/base/langflow/components/helpers/store_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from langflow.utils.constants import MESSAGE_SENDER_AI, MESSAGE_SENDER_NAME_AI


class StoreMessageComponent(Component):
display_name = "Store Message"
class MessageStoreComponent(Component):
display_name = "Message Store"
description = "Stores a chat message or text into Langflow tables or an external memory."
icon = "save"
icon = "message-square-text"
name = "StoreMessage"

inputs = [
Expand Down Expand Up @@ -46,7 +46,7 @@ class StoreMessageComponent(Component):
]

outputs = [
Output(display_name="Stored Message", name="stored_message", method="store_message"),
Output(display_name="Stored Messages", name="stored_messages", method="store_message", hidden=True),
]

async def store_message(self) -> Message:
Expand Down
11 changes: 10 additions & 1 deletion src/backend/base/langflow/components/langchain_utilities/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from langflow.base.agents.agent import LCAgentComponent
from langflow.field_typing import AgentExecutor
from langflow.inputs import DropdownInput, FileInput, HandleInput
from langflow.inputs.inputs import MessageTextInput
from langflow.inputs.inputs import DictInput, MessageTextInput
from langflow.schema.message import Message
from langflow.template.field.base import Output

Expand Down Expand Up @@ -44,6 +44,13 @@ class CSVAgentComponent(LCAgentComponent):
display_name="Text",
info="Text to be passed as input and extract info from the CSV File.",
),
DictInput(
name="pandas_kwargs",
display_name="Pandas Kwargs",
info="Pandas Kwargs to be passed to the agent.",
advanced=True,
is_list=True,
),
]

outputs = [
Expand All @@ -67,6 +74,7 @@ def build_agent_response(self) -> Message:
path=self._path(),
agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors,
pandas_kwargs=self.pandas_kwargs,
**agent_kwargs,
)

Expand All @@ -84,6 +92,7 @@ def build_agent(self) -> AgentExecutor:
path=self._path(),
agent_type=self.agent_type,
handle_parsing_errors=self.handle_parsing_errors,
pandas_kwargs=self.pandas_kwargs,
**agent_kwargs,
)

Expand Down
2 changes: 2 additions & 0 deletions src/backend/base/langflow/components/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .nvidia import NVIDIAModelComponent
from .ollama import ChatOllamaComponent
from .openai import OpenAIModelComponent
from .openrouter import OpenRouterComponent
from .perplexity import PerplexityComponent
from .sambanova import SambaNovaComponent
from .vertexai import ChatVertexAIComponent
Expand All @@ -33,6 +34,7 @@
"MistralAIModelComponent",
"NVIDIAModelComponent",
"OpenAIModelComponent",
"OpenRouterComponent",
"PerplexityComponent",
"QianfanChatEndpointComponent",
"SambaNovaComponent",
Expand Down
Loading

0 comments on commit 5b60795

Please sign in to comment.