Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: A piece of code in chat service #4297

Open
czhcc opened this issue Dec 31, 2024 · 2 comments
Open

[Question]: A piece of code in chat service #4297

czhcc opened this issue Dec 31, 2024 · 2 comments
Labels
question Further information is requested

Comments

@czhcc
Copy link

czhcc commented Dec 31, 2024

Describe your problem

聊天功能处理代码,dialog_service.py中147行的
llm = LLMService.query(llm_name=llm_id) if not model_provider else LLMService.query(llm_name=llm_id, fid=model_provider)
这段的处理,对于自定义的LLM,是查询不出结果,到下面的if判断中,max_tokens的值只能是8192。而自定义的模型max_tokens可以更大。
现在这样处理是不是有问题?

@czhcc czhcc added the question Further information is requested label Dec 31, 2024
@danny-zhu
Copy link

danny-zhu commented Dec 31, 2024

我把它改成了下面这样,原来的写法有潜在的bug:

    max_tokens  = 8192
    if not llm:
        # Model name is provided by tenant, but not system built-in
        llm = TenantLLMService.query(tenant_id=dialog.tenant_id, llm_name=llm_id) if not model_provider else \
            TenantLLMService.query(tenant_id=dialog.tenant_id, llm_name=llm_id, llm_factory=model_provider)
        if not llm:
            raise LookupError("LLM(%s) not found" % dialog.llm_id)
    if llm and llm[0] and hasattr(llm[0], 'max_tokens'):
        max_tokens = llm[0].max_tokens

@czhcc
Copy link
Author

czhcc commented Dec 31, 2024

但自定义的模型写法是
my-m5___LocalAI
这样时,max_tokens还是固定的8192,不能使用聊天的模型配置中的最大token数的配置值

@JinHai-CN JinHai-CN changed the title [Question]: 聊天功能一段代码的问题 [Question]: A piece of code in chat service Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants