mirror of
https://github.com/langflow-ai/langflow.git
synced 2026-07-24 10:50:35 +08:00
feat(cuga): new cuga release (#10559)
* feat(cuga): new cuga release * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) * [autofix.ci] apply automated fixes * [autofix.ci] apply automated fixes (attempt 2/3) --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@ -134,7 +134,7 @@ dependencies = [
|
||||
"fastparquet>=2024.11.0,<2025.0.0",
|
||||
"traceloop-sdk>=0.43.1,<1.0.0",
|
||||
"vlmrun[all]>=0.2.0",
|
||||
"cuga==0.1.2",
|
||||
"cuga==0.1.4",
|
||||
"agent-lifecycle-toolkit",
|
||||
"astrapy>=2.1.0,<3.0.0",
|
||||
]
|
||||
|
||||
@ -72,6 +72,8 @@ class TestCugaComponent(ComponentTestBaseWithoutClient):
|
||||
"browser_enabled": False,
|
||||
"web_apps": "",
|
||||
"API": False,
|
||||
"lite_mode": True,
|
||||
"lite_mode_tool_threshold": 25,
|
||||
}
|
||||
|
||||
async def test_build_config_update(self, component_class, default_kwargs):
|
||||
@ -389,6 +391,8 @@ class TestCugaComponent(ComponentTestBaseWithoutClient):
|
||||
assert "browser_enabled" in input_names
|
||||
assert "web_apps" in input_names
|
||||
assert "API" in input_names
|
||||
assert "lite_mode" in input_names
|
||||
assert "lite_mode_tool_threshold" in input_names
|
||||
|
||||
# Verify default values
|
||||
assert hasattr(component, "policies")
|
||||
@ -398,9 +402,13 @@ class TestCugaComponent(ComponentTestBaseWithoutClient):
|
||||
assert hasattr(component, "browser_enabled")
|
||||
assert hasattr(component, "web_apps")
|
||||
assert hasattr(component, "API")
|
||||
assert hasattr(component, "lite_mode")
|
||||
assert hasattr(component, "lite_mode_tool_threshold")
|
||||
assert component.n_messages == 100
|
||||
assert component.browser_enabled is False
|
||||
assert component.API is False
|
||||
assert component.lite_mode is True
|
||||
assert component.lite_mode_tool_threshold == 25
|
||||
|
||||
async def test_cuga_has_correct_outputs(self, component_class, default_kwargs):
|
||||
"""Test that Cuga component has the correct output configuration.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -1,6 +1,5 @@
|
||||
import asyncio
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
import uuid
|
||||
@ -108,9 +107,9 @@ class CugaComponent(ToolCallingAgentComponent):
|
||||
info=(
|
||||
"Custom instructions or policies for the agent to adhere to during its operation.\n"
|
||||
"Example:\n"
|
||||
"# Plan\n"
|
||||
"## Plan\n"
|
||||
"< planning instructions e.g. which tools and when to use>\n"
|
||||
"# Answer\n"
|
||||
"## Answer\n"
|
||||
"< final answer instructions how to answer>"
|
||||
),
|
||||
value="",
|
||||
@ -193,6 +192,20 @@ class CugaComponent(ToolCallingAgentComponent):
|
||||
info="If true, will add a tool to the agent that returns the current date.",
|
||||
value=True,
|
||||
),
|
||||
BoolInput(
|
||||
name="lite_mode",
|
||||
display_name="Enable CugaLite",
|
||||
info="Enable CugaLite for simple API tasks (faster execution).",
|
||||
value=True,
|
||||
advanced=False,
|
||||
),
|
||||
IntInput(
|
||||
name="lite_mode_tool_threshold",
|
||||
display_name="CugaLite Tool Threshold",
|
||||
info="Route to CugaLite if app has fewer than this many tools.",
|
||||
value=25,
|
||||
advanced=False,
|
||||
),
|
||||
BoolInput(
|
||||
name="browser_enabled",
|
||||
display_name="Enable Browser",
|
||||
@ -254,33 +267,27 @@ class CugaComponent(ToolCallingAgentComponent):
|
||||
}
|
||||
logger.debug(f"LLM MODEL TYPE: {type(llm)}")
|
||||
if current_input:
|
||||
try:
|
||||
from cuga.config import settings as cuga_settings
|
||||
# Import settings first
|
||||
from cuga.config import settings
|
||||
|
||||
logger.info("Updating cuga settings programmatically")
|
||||
cuga_settings.set("advanced_features.registry", False) # noqa: FBT003
|
||||
# Use Dynaconf's set() method to update settings dynamically
|
||||
# This properly updates the settings object without corruption
|
||||
logger.debug("Updating CUGA settings via Dynaconf set() method")
|
||||
|
||||
if self.browser_enabled:
|
||||
logger.info("browser_enabled is true, setting mode to hybrid")
|
||||
cuga_settings.set("advanced_features.mode", "hybrid")
|
||||
cuga_settings.set("advanced_features.use_vision", False) # noqa: FBT003
|
||||
else:
|
||||
logger.info("browser_enabled is false, setting mode to api")
|
||||
cuga_settings.set("advanced_features.mode", "api")
|
||||
settings.advanced_features.registry = False
|
||||
settings.advanced_features.lite_mode = self.lite_mode
|
||||
settings.advanced_features.lite_mode_tool_threshold = self.lite_mode_tool_threshold
|
||||
|
||||
logger.info(f"Cuga settings updated - MODE: {cuga_settings.get('advanced_features.mode')}")
|
||||
except (ImportError, AttributeError) as e:
|
||||
logger.warning(f"Could not update cuga settings: {e}")
|
||||
os.environ["DYNACONF_ADVANCED_FEATURES__REGISTRY"] = "false"
|
||||
if self.browser_enabled:
|
||||
logger.info("browser_enabled is true, setting env to hybrid")
|
||||
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "hybrid"
|
||||
os.environ["DYNACONF_ADVANCED_FEATURES__USE_VISION"] = "false"
|
||||
else:
|
||||
logger.info("browser_enabled is false, setting env to api")
|
||||
os.environ["DYNACONF_ADVANCED_FEATURES__MODE"] = "api"
|
||||
if self.browser_enabled:
|
||||
logger.info("browser_enabled is true, setting mode to hybrid")
|
||||
settings.advanced_features.mode = "hybrid"
|
||||
settings.advanced_features.use_vision = False
|
||||
else:
|
||||
logger.info("browser_enabled is false, setting mode to api")
|
||||
settings.advanced_features.mode = "api"
|
||||
|
||||
from cuga.backend.activity_tracker.tracker import ActivityTracker
|
||||
from cuga.backend.cuga_graph.nodes.api.variables_manager.manager import VariablesManager
|
||||
from cuga.backend.cuga_graph.utils.agent_loop import StreamEvent
|
||||
from cuga.backend.cuga_graph.utils.controller import (
|
||||
AgentRunner as CugaAgent,
|
||||
@ -291,6 +298,16 @@ class CugaComponent(ToolCallingAgentComponent):
|
||||
from cuga.backend.llm.models import LLMManager
|
||||
from cuga.configurations.instructions_manager import InstructionsManager
|
||||
|
||||
var_manager = VariablesManager()
|
||||
|
||||
# Reset var_manager if this is the first message in history
|
||||
logger.info(f"[CUGA] Checking history_messages: count={len(history_messages) if history_messages else 0}")
|
||||
if not history_messages or len(history_messages) == 0:
|
||||
logger.info("[CUGA] First message in history detected, resetting var_manager")
|
||||
var_manager.reset()
|
||||
else:
|
||||
logger.info(f"[CUGA] Continuing conversation with {len(history_messages)} previous messages")
|
||||
|
||||
llm_manager = LLMManager()
|
||||
llm_manager.set_llm(llm)
|
||||
instructions_manager = InstructionsManager()
|
||||
@ -760,11 +777,13 @@ class CugaComponent(ToolCallingAgentComponent):
|
||||
list: List of Message objects representing the chat history
|
||||
"""
|
||||
logger.info("[CUGA] Retrieving chat history messages.")
|
||||
logger.info(f"[CUGA] Session ID: {self.graph.session_id}")
|
||||
messages = (
|
||||
await MemoryComponent(**self.get_base_args())
|
||||
.set(session_id=self.graph.session_id, order="Ascending", n_messages=self.n_messages)
|
||||
.retrieve_messages()
|
||||
)
|
||||
logger.info(f"[CUGA] Retrieved {len(messages)} messages from memory")
|
||||
return [
|
||||
message for message in messages if getattr(message, "id", None) != getattr(self.input_value, "id", None)
|
||||
]
|
||||
|
||||
8
uv.lock
generated
8
uv.lock
generated
@ -1800,7 +1800,7 @@ wheels = [
|
||||
|
||||
[[package]]
|
||||
name = "cuga"
|
||||
version = "0.1.2"
|
||||
version = "0.1.4"
|
||||
source = { registry = "https://pypi.org/simple" }
|
||||
dependencies = [
|
||||
{ name = "aiohttp" },
|
||||
@ -1825,9 +1825,9 @@ dependencies = [
|
||||
{ name = "typer" },
|
||||
{ name = "uvicorn" },
|
||||
]
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/50/44/fe12f258facf510f75fd5ff67e1afc01d753a976e9a76fd50ca677ed9167/cuga-0.1.2.tar.gz", hash = "sha256:cdc2d8f4651d6b97e4b3bff8e65e70d03f4668ddfe1e7bb5a6269a0fbbbdd660", size = 13102228, upload-time = "2025-10-16T15:48:09.486Z" }
|
||||
sdist = { url = "https://files.pythonhosted.org/packages/7b/b8/24514ec772f0a3401fd06fbe3d2c342abfbaf6fa0541223b32078c60cfde/cuga-0.1.4.tar.gz", hash = "sha256:74db548ec7217198e1542818c5f277f62510d868c76a59f21ae413ec2dfbb876", size = 12989068, upload-time = "2025-11-11T13:05:03.309Z" }
|
||||
wheels = [
|
||||
{ url = "https://files.pythonhosted.org/packages/d4/fb/92812a8bc40e2f2dc3d91732965373ada50d9dc32045e1b9ff1117a1532f/cuga-0.1.2-py3-none-any.whl", hash = "sha256:1976b47d60648d8e12a0b3a1109febe556f15be2116502c05a638d3c651399cd", size = 13648611, upload-time = "2025-10-16T15:48:04.705Z" },
|
||||
{ url = "https://files.pythonhosted.org/packages/75/3d/133813413b21bef2744bcb1c29563880b1a1482f79c67168d87c40486085/cuga-0.1.4-py3-none-any.whl", hash = "sha256:822b09035734718d1ac37d8253bab04a7356d220530397b31dc10538b6cb8f77", size = 13563221, upload-time = "2025-11-11T13:05:00.081Z" },
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -5602,7 +5602,7 @@ requires-dist = [
|
||||
{ name = "couchbase", marker = "extra == 'couchbase'", specifier = ">=4.2.1" },
|
||||
{ name = "cryptography", specifier = ">=43.0.1,<44.0.0" },
|
||||
{ name = "ctransformers", marker = "extra == 'local'", specifier = ">=0.2.10" },
|
||||
{ name = "cuga", specifier = "==0.1.2" },
|
||||
{ name = "cuga", specifier = "==0.1.4" },
|
||||
{ name = "datasets", specifier = ">2.14.7,<4.0.0" },
|
||||
{ name = "docling", marker = "platform_machine != 'x86_64' or sys_platform != 'darwin'", specifier = ">=2.36.1,<3.0.0" },
|
||||
{ name = "docling-core", specifier = ">=2.36.1,<3.0.0" },
|
||||
|
||||
Reference in New Issue
Block a user