mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-02 01:23:07 +00:00
fix: Fix LLM mimicking Unicode responses due to forced Unicode conversion of non-ASCII characters. - **Description:** This PR fixes an issue where the LLM would mimic Unicode responses due to forced Unicode conversion of non-ASCII characters in tool calls. The fix involves disabling the `ensure_ascii` flag in `json.dumps()` when converting tool calls to OpenAI format. - **Issue:** Fixes ↓↓↓ input: ```json {'role': 'assistant', 'tool_calls': [{'type': 'function', 'id': 'call_nv9trcehdpihr21zj9po19vq', 'function': {'name': 'create_customer', 'arguments': '{"customer_name": "你好啊集团"}'}}]} ``` output: ```json {'role': 'assistant', 'tool_calls': [{'type': 'function', 'id': 'call_nv9trcehdpihr21zj9po19vq', 'function': {'name': 'create_customer', 'arguments': '{"customer_name": "\\u4f60\\u597d\\u554a\\u96c6\\u56e2"}'}}]} ``` then: llm will mimic outputting unicode. Unicode's vast number of symbols can lengthen LLM responses, leading to slower performance. <img width="686" height="277" alt="image" src="https://github.com/user-attachments/assets/28f3b007-3964-4455-bee2-68f86ac1906d" /> --------- Co-authored-by: Mason Daugherty <github@mdrxy.com> Co-authored-by: Mason Daugherty <mason@langchain.dev>
108 lines
3.2 KiB
TOML
108 lines
3.2 KiB
TOML
[build-system]
|
|
requires = ["pdm-backend"]
|
|
build-backend = "pdm.backend"
|
|
|
|
[project]
|
|
authors = [{ name = "Erick Friis", email = "erick@langchain.dev" }]
|
|
license = { text = "MIT" }
|
|
requires-python = ">=3.9"
|
|
dependencies = [
|
|
"typer[all]<1.0.0,>=0.9.0",
|
|
"gitpython<4,>=3",
|
|
"langserve[all]>=0.0.51",
|
|
"uvicorn<1.0,>=0.23",
|
|
"tomlkit>=0.12",
|
|
"gritql<1.0.0,>=0.2.0",
|
|
]
|
|
name = "langchain-cli"
|
|
version = "0.0.36"
|
|
description = "CLI for interacting with LangChain"
|
|
readme = "README.md"
|
|
|
|
[project.urls]
|
|
"Source Code" = "https://github.com/langchain-ai/langchain/tree/master/libs/cli"
|
|
"Release Notes" = "https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-cli%3D%3D0%22&expanded=true"
|
|
repository = "https://github.com/langchain-ai/langchain"
|
|
|
|
[project.scripts]
|
|
langchain = "langchain_cli.cli:app"
|
|
langchain-cli = "langchain_cli.cli:app"
|
|
|
|
[dependency-groups]
|
|
dev = ["pytest<8.0.0,>=7.4.2", "pytest-watcher<1.0.0,>=0.3.4"]
|
|
lint = ["ruff<0.13,>=0.12.2", "mypy<2.0.0,>=1.13.0"]
|
|
test = ["langchain-core", "langchain"]
|
|
typing = ["langchain"]
|
|
test_integration = []
|
|
|
|
[tool.uv.sources]
|
|
langchain-core = { path = "../core", editable = true }
|
|
langchain = { path = "../langchain", editable = true }
|
|
|
|
[tool.ruff]
|
|
target-version = "py39"
|
|
exclude = [
|
|
"langchain_cli/integration_template",
|
|
"langchain_cli/package_template",
|
|
"langchain_cli/project_template",
|
|
]
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"A", # flake8-builtins
|
|
"B", # flake8-bugbear
|
|
"ARG", # flake8-unused-arguments
|
|
"ASYNC", # flake8-async
|
|
"C4", # flake8-comprehensions
|
|
"COM", # flake8-commas
|
|
"D", # pydocstyle
|
|
"E", # pycodestyle error
|
|
"EM", # flake8-errmsg
|
|
"F", # pyflakes
|
|
"FA", # flake8-future-annotations
|
|
"FBT", # flake8-boolean-trap
|
|
"FLY", # flake8-flynt
|
|
"I", # isort
|
|
"ICN", # flake8-import-conventions
|
|
"INT", # flake8-gettext
|
|
"ISC", # isort-comprehensions
|
|
"N", # pep8-naming
|
|
"PT", # flake8-pytest-style
|
|
"PGH", # pygrep-hooks
|
|
"PIE", # flake8-pie
|
|
"PERF", # flake8-perf
|
|
"PYI", # flake8-pyi
|
|
"Q", # flake8-quotes
|
|
"RET", # flake8-return
|
|
"RSE", # flake8-rst-docstrings
|
|
"RUF", # ruff
|
|
"S", # flake8-bandit
|
|
"SLF", # flake8-self
|
|
"SLOT", # flake8-slots
|
|
"SIM", # flake8-simplify
|
|
"T10", # flake8-debugger
|
|
"T20", # flake8-print
|
|
"TID", # flake8-tidy-imports
|
|
"UP", # pyupgrade
|
|
"W", # pycodestyle warning
|
|
"YTT", # flake8-2020
|
|
]
|
|
ignore = [
|
|
"D100", # pydocstyle: Missing docstring in public module
|
|
"D101", # pydocstyle: Missing docstring in public class
|
|
"D102", # pydocstyle: Missing docstring in public method
|
|
"D103", # pydocstyle: Missing docstring in public function
|
|
"D104", # pydocstyle: Missing docstring in public package
|
|
"D105", # pydocstyle: Missing docstring in magic method
|
|
"D107", # pydocstyle: Missing docstring in __init__
|
|
"D407", # pydocstyle: Missing-dashed-underline-after-section
|
|
"COM812", # Messes with the formatter
|
|
]
|
|
pyupgrade.keep-runtime-typing = true
|
|
|
|
[tool.mypy]
|
|
exclude = [
|
|
"langchain_cli/integration_template",
|
|
"langchain_cli/package_template",
|
|
]
|