Merge remote-tracking branch 'origin/dev' into cz/mergeAll
This commit is contained in:
commit
2b2812f4df
5 changed files with 37 additions and 34 deletions
26
poetry.lock
generated
26
poetry.lock
generated
|
|
@ -2584,13 +2584,13 @@ grpcio-gcp = ["grpcio-gcp (>=0.2.2,<1.0.dev0)"]
|
|||
|
||||
[[package]]
|
||||
name = "google-api-python-client"
|
||||
version = "2.132.0"
|
||||
version = "2.133.0"
|
||||
description = "Google API Client Library for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "google-api-python-client-2.132.0.tar.gz", hash = "sha256:d6340dc83b72d72333cee5d50f7dcfecbff66a8783164090e945f985ec4c374d"},
|
||||
{file = "google_api_python_client-2.132.0-py2.py3-none-any.whl", hash = "sha256:cde87700bd4d37f39f5e940292c1c6cd0910990b5b01f50b1332a8cea38e8595"},
|
||||
{file = "google-api-python-client-2.133.0.tar.gz", hash = "sha256:293092905b66a046d3187a99ac454e12b00cc2c70444f26eb2f1f9c1a82720b4"},
|
||||
{file = "google_api_python_client-2.133.0-py2.py3-none-any.whl", hash = "sha256:396fe676ea0dfed066654dcf9f8dea77a1342f9d9bb23bb88e45b7b81e773926"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
@ -4377,7 +4377,7 @@ six = "*"
|
|||
|
||||
[[package]]
|
||||
name = "langflow-base"
|
||||
version = "0.0.61"
|
||||
version = "0.0.62"
|
||||
description = "A Python package with a built-in web application"
|
||||
optional = false
|
||||
python-versions = ">=3.10,<3.13"
|
||||
|
|
@ -4434,13 +4434,13 @@ url = "src/backend/base"
|
|||
|
||||
[[package]]
|
||||
name = "langfuse"
|
||||
version = "2.35.2"
|
||||
version = "2.36.0"
|
||||
description = "A client library for accessing langfuse"
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.8.1"
|
||||
files = [
|
||||
{file = "langfuse-2.35.2-py3-none-any.whl", hash = "sha256:d01a23842cab484594f03878aacb9732ef8fd361158eb819c7bf43f758a0954b"},
|
||||
{file = "langfuse-2.35.2.tar.gz", hash = "sha256:32b2e6c5bc71b4efdc430c6b964ab1c1e1ba1e105a4a73912c38b3959dc4502d"},
|
||||
{file = "langfuse-2.36.0-py3-none-any.whl", hash = "sha256:6991895aa52d4702ab5ee9eb8fd5ebe129862e103db4ba8cd2b34c352e07abc5"},
|
||||
{file = "langfuse-2.36.0.tar.gz", hash = "sha256:51fad5bb20947342d0e49d2c4847221b3d2630b590cf701bcfb07a09918ddc0d"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
@ -6934,13 +6934,13 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0"
|
|||
|
||||
[[package]]
|
||||
name = "pydantic-settings"
|
||||
version = "2.3.1"
|
||||
version = "2.3.2"
|
||||
description = "Settings management using Pydantic"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pydantic_settings-2.3.1-py3-none-any.whl", hash = "sha256:acb2c213140dfff9669f4fe9f8180d43914f51626db28ab2db7308a576cce51a"},
|
||||
{file = "pydantic_settings-2.3.1.tar.gz", hash = "sha256:e34bbd649803a6bb3e2f0f58fb0edff1f0c7f556849fda106cc21bcce12c30ab"},
|
||||
{file = "pydantic_settings-2.3.2-py3-none-any.whl", hash = "sha256:ae06e44349e4c7bff8d57aff415dfd397ae75c217a098d54e9e6990ad7594ac7"},
|
||||
{file = "pydantic_settings-2.3.2.tar.gz", hash = "sha256:05d33003c74c2cd585de97b59eb17b6ed67181bc8a3ce594d74b5d24e4df7323"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
@ -8618,13 +8618,13 @@ typing = ["mypy (>=1.4)", "rich", "twisted"]
|
|||
|
||||
[[package]]
|
||||
name = "supabase"
|
||||
version = "2.5.0"
|
||||
version = "2.5.1"
|
||||
description = "Supabase client for Python."
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.8"
|
||||
files = [
|
||||
{file = "supabase-2.5.0-py3-none-any.whl", hash = "sha256:13e5ed9e9377a1a69e70ad18ed7b82997cf13ffcd28173952f7503e4d5067771"},
|
||||
{file = "supabase-2.5.0.tar.gz", hash = "sha256:133dc832dfdd617f2f90ac5b52664df96ac8a9302ac6656ee769dc3f545812f0"},
|
||||
{file = "supabase-2.5.1-py3-none-any.whl", hash = "sha256:74a1f24f04fede1967ef084b50dea688228f7b10eb2f9d73350fe2251a865188"},
|
||||
{file = "supabase-2.5.1.tar.gz", hash = "sha256:c50e0eba5b03de3abd5ac0f887957ca43558ba44c4d17bb44e73ec454b41734c"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "langflow"
|
||||
version = "1.0.0a50"
|
||||
version = "1.0.0a51"
|
||||
description = "A Python package with a built-in web application"
|
||||
authors = ["Langflow <contact@langflow.org>"]
|
||||
maintainers = [
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
from typing import Any, Dict, List, Callable
|
||||
import ast
|
||||
from typing import Any, Dict, List, Optional
|
||||
|
||||
from langchain.agents import Tool
|
||||
from langchain.tools import StructuredTool
|
||||
from langflow.interface.custom.custom_component import CustomComponent
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
from langflow.schema.dotdict import dotdict
|
||||
from langchain.pydantic_v1 import BaseModel, Field
|
||||
|
||||
|
||||
class PythonCodeStructuredTool(CustomComponent):
|
||||
|
|
@ -12,8 +13,7 @@ class PythonCodeStructuredTool(CustomComponent):
|
|||
description = "structuredtool dataclass code to tool"
|
||||
documentation = "https://python.langchain.com/docs/modules/tools/custom_tools/#structuredtool-dataclass"
|
||||
icon = "🐍"
|
||||
field_order = ["name", "description", "tool_code",
|
||||
"return_direct", "tool_function", "tool_class"]
|
||||
field_order = ["name", "description", "tool_code", "return_direct", "tool_function", "tool_class"]
|
||||
|
||||
def build_config(self) -> Dict[str, Any]:
|
||||
return {
|
||||
|
|
@ -23,6 +23,7 @@ class PythonCodeStructuredTool(CustomComponent):
|
|||
"placeholder": "def my_function(args):\n pass",
|
||||
"multiline": True,
|
||||
"refresh_button": True,
|
||||
"field_type": "code",
|
||||
},
|
||||
"name": {
|
||||
"display_name": "Tool Name",
|
||||
|
|
@ -53,10 +54,8 @@ class PythonCodeStructuredTool(CustomComponent):
|
|||
|
||||
def parse_source_name(self, code: str) -> Dict:
|
||||
parsed_code = ast.parse(code)
|
||||
class_names = [
|
||||
node.name for node in parsed_code.body if isinstance(node, ast.ClassDef)]
|
||||
function_names = [
|
||||
node.name for node in parsed_code.body if isinstance(node, ast.FunctionDef)]
|
||||
class_names = [node.name for node in parsed_code.body if isinstance(node, ast.ClassDef)]
|
||||
function_names = [node.name for node in parsed_code.body if isinstance(node, ast.FunctionDef)]
|
||||
return {"class": class_names, "function": function_names}
|
||||
|
||||
def update_build_config(self, build_config: dotdict, field_value: Any, field_name: str | None = None) -> dotdict:
|
||||
|
|
@ -71,8 +70,16 @@ class PythonCodeStructuredTool(CustomComponent):
|
|||
build_config.tool_function.options = []
|
||||
return build_config
|
||||
|
||||
async def build(self, tool_code: Code, name: str, description: str, tool_function: List[str], return_direct: bool, tool_class: List[str] = None) -> Tool:
|
||||
local_namespace = {}
|
||||
async def build(
|
||||
self,
|
||||
tool_code: str,
|
||||
name: str,
|
||||
description: str,
|
||||
tool_function: List[str],
|
||||
return_direct: bool,
|
||||
tool_class: Optional[List[str]] = None,
|
||||
) -> Tool:
|
||||
local_namespace = {} # type: ignore
|
||||
exec(tool_code, globals(), local_namespace)
|
||||
|
||||
func = local_namespace[tool_function]
|
||||
|
|
@ -82,10 +89,6 @@ class PythonCodeStructuredTool(CustomComponent):
|
|||
_class = local_namespace[tool_class]
|
||||
|
||||
tool = StructuredTool.from_function(
|
||||
func=func,
|
||||
args_schema=_class,
|
||||
name=name,
|
||||
description=description,
|
||||
return_direct=return_direct
|
||||
func=func, args_schema=_class, name=name, description=description, return_direct=return_direct
|
||||
)
|
||||
return tool
|
||||
|
|
|
|||
6
src/backend/base/poetry.lock
generated
6
src/backend/base/poetry.lock
generated
|
|
@ -2193,13 +2193,13 @@ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0"
|
|||
|
||||
[[package]]
|
||||
name = "pydantic-settings"
|
||||
version = "2.3.1"
|
||||
version = "2.3.2"
|
||||
description = "Settings management using Pydantic"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pydantic_settings-2.3.1-py3-none-any.whl", hash = "sha256:acb2c213140dfff9669f4fe9f8180d43914f51626db28ab2db7308a576cce51a"},
|
||||
{file = "pydantic_settings-2.3.1.tar.gz", hash = "sha256:e34bbd649803a6bb3e2f0f58fb0edff1f0c7f556849fda106cc21bcce12c30ab"},
|
||||
{file = "pydantic_settings-2.3.2-py3-none-any.whl", hash = "sha256:ae06e44349e4c7bff8d57aff415dfd397ae75c217a098d54e9e6990ad7594ac7"},
|
||||
{file = "pydantic_settings-2.3.2.tar.gz", hash = "sha256:05d33003c74c2cd585de97b59eb17b6ed67181bc8a3ce594d74b5d24e4df7323"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "langflow-base"
|
||||
version = "0.0.61"
|
||||
version = "0.0.62"
|
||||
description = "A Python package with a built-in web application"
|
||||
authors = ["Langflow <contact@langflow.org>"]
|
||||
maintainers = [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue