Skip to content

Conversation

yechaoying
Copy link

@yechaoying yechaoying commented Mar 20, 2025

Langchain-Chatchat/libs/chatchat-server/chatchat/server/api_server/chat_routes.py 中,max_tokens 的定义为:

# 当调用本接口且请求体中没有传入 "max_tokens" 参数时,默认使用配置中定义的值
if body.max_tokens in [None, 0]:
    body.max_tokens = Settings.model_settings.MAX_TOKENS
然而Settings 中对 MAX_TOKENS 的解释为MAX_TOKENS: t.Optional[int] = None  # 大模型支持的最大长度,如果未设置,则使用模型的默认最大长度;如果设置了,则为用户指定的最大长度
这意味着如果 max_tokens 未在请求体中提供系统将使用配置中的 MAX_TOKENS 作为默认值此处不应设None

在 `Langchain-Chatchat/libs/chatchat-server/chatchat/server/api_server/chat_routes.py` 中,`max_tokens` 的定义为:

```python
# 当调用本接口且请求体中没有传入 "max_tokens" 参数时,默认使用配置中定义的值
if body.max_tokens in [None, 0]:
    body.max_tokens = Settings.model_settings.MAX_TOKENS
然而,Settings 中对 MAX_TOKENS 的解释为:

python
复制
MAX_TOKENS: t.Optional[int] = None  # 大模型支持的最大长度,如果未设置,则使用模型的默认最大长度;如果设置了,则为用户指定的最大长度
这意味着,如果 max_tokens 未在请求体中提供,系统将使用配置中的 MAX_TOKENS 作为默认值,此处不应设None
@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant