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

[Bug]: ollama 模型中的“保持活跃时间“选项无效 #1938

Open
3 tasks done
zhaobenx opened this issue Feb 18, 2025 · 7 comments
Open
3 tasks done

[Bug]: ollama 模型中的“保持活跃时间“选项无效 #1938

zhaobenx opened this issue Feb 18, 2025 · 7 comments
Assignees
Labels
bug Something isn't working good first issue A good first task for someone new developers

Comments

@zhaobenx
Copy link

zhaobenx commented Feb 18, 2025

Issue Checklist

  • I understand that issues are for feedback and problem solving, not for complaining in the comment section, and will provide as much information as possible to help solve the problem.
  • I've looked at pinned issues and searched for existing Open Issues and Closed Issues, no similar issue was found.
  • I've filled in short, clear headings so that developers can quickly identify a rough idea of what to expect when flipping through the list of issues. And not "a suggestion", "stuck", etc.

Platform

Windows

Version

v0.9.24

Bug Description

在模型服务-ollama中,保持活跃时间的选项不起作用,如图所示,

Image

在我设置其活跃时间为15分钟后,进行对话之后,由命令行执行 ollama ps后显示的时间还是五分钟:

PS C:\Users\user> ollama ps
NAME               ID              SIZE     PROCESSOR    UNTIL
deepseek-r1:14b    ea35dfe18182    11 GB    100% GPU     4 minutes from now

Steps To Reproduce

在模型服务-ollama中,调整保持活跃时间的选项,然后执行问答/检查api密钥以刷新模型存活时间

命令行执行 ollama ps,观察其UNTIL栏目

Expected Behavior

Until应该随保持活跃时间变动而变动

Relevant Log Output

Additional Context

No response

@zhaobenx zhaobenx added the bug Something isn't working label Feb 18, 2025
@TeacherTan TeacherTan self-assigned this Feb 18, 2025
@FischLu
Copy link
Contributor

FischLu commented Feb 19, 2025

抓一下包, 软件应该是成功的把 keep_alive 参数发出了, 你在你电脑上运行下面的命令, 如果 ollama 活跃时间没有变成 15分钟, 那可能是 ollama 的问题

curl -X POST http://localhost:11434/api/generate -d '{
  "model": "deepseek-r1:32b",
  "keep_alive": "15m",
  "prompt":"hello"
 }'

@zhaobenx
Copy link
Author

抓一下包, 软件应该是成功的把 keep_alive 参数发出了, 你在你电脑上运行下面的命令, 如果 ollama 活跃时间没有变成 15分钟, 那可能是 ollama 的问题

curl -X POST http://localhost:11434/api/generate -d '{
  "model": "deepseek-r1:32b",
  "keep_alive": "15m",
  "prompt":"hello"
 }'

命令行跑了一下发现确实变了,但是在cherrystudio中,改了时间然后点击API密钥-检查,还是没有改变,打开控制台发现http://localhost:11434/v1/chat/completions 的payload是

{
  "model": "deepseek-r1:14b",
  "messages": [
    {
      "role": "user",
      "content": "hi"
    }
  ],
  "stream": false
}

即在点击检查按钮时这里并没有带上keepalive参数。同时我发现在聊天时也使用这个api,带上了keepalive参数同样没有用,于是我查了一下ollama的api文档,似乎里面并没有/chat/completions 这个api,而如果用其官方的 api/chat 带keepalive参数的话就可以正确设置存活时间了。

当然我对ollama和大语言模型不是很熟悉,我感觉是不是可以从两方面改正:

  1. 在点击“检查”按钮时也加上keepalive
  2. 将api改成官方文档中的api/chat?

@TeacherTan
Copy link
Collaborator

感谢反馈

@TeacherTan TeacherTan added the good first issue A good first task for someone new developers label Feb 19, 2025
@zhaobenx
Copy link
Author

我看了一下ollama的源码,chat/completions (https://github.com/ollama/ollama/blob/d2eb226c914aa86f2a371c340997d6e26e2aecef/server/routes.go#L1161)这个api应该是兼容openai的api的,而原版的[openai的api](https://platform.openai.com/docs/api-reference/chat/create) 中确实没有keep alive参数,所以导致使用 completions这个api时无法实现模型存活时间的修改。

@FischLu
Copy link
Contributor

FischLu commented Feb 19, 2025

那可以改一下 cherrystudio 用的 api, 调试一下用api/generate有没有其他兼容问题

@FischLu
Copy link
Contributor

FischLu commented Feb 19, 2025

不过 ollama 服务器端应该支持 OLLAMA_KEEP_ALIVE 环境变量吧, 你至少可以设置这个值为 15m

@kangfenmao
Copy link
Collaborator

将会去掉这个参数的设置选项

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue A good first task for someone new developers
Projects
None yet
Development

No branches or pull requests

4 participants