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

feat: add Max Tokens and Context Window Setting Options for Ollama Channel #1694

Merged
merged 9 commits into from
Aug 6, 2024

Conversation

MotorBottle
Copy link
Contributor

@MotorBottle MotorBottle commented Jul 25, 2024

已实现:

  1. 支持通过max_tokens(对应ollama的num_predict)参数限制输出token数
  2. 支持通过num_ctx(ollama原生参数)参数设定更改ollama默认context window大小(默认仅1k/2k上下文)

有个问题:
下图中改动的部分是因为原本的代码会导致报错,console打印后发现原本的data就是正确的json格式不需要对花括号进行增减处理。但奇怪的是目前我通过docker compose部署的正式版本也是能正常使用的,正式版本并没有我对这两行的修改(也可能部署的版本本来没有这两行?没有去查看,总之修改之后添加了条件判断,对两种不同状况都能有效应对)。
目前已确认并非个案, #1702 也是同样的问题,但我觉得条件判断会比直接改掉健壮性更强
image

close #1691

我已确认该 PR 已自测通过,相关截图如下:
image
image

@MotorBottle MotorBottle changed the title Add max_tokens compability for Ollama Channel Add Max Tokens and Context Window Setting Options for Ollama Channel Jul 26, 2024
@SLKun
Copy link
Contributor

SLKun commented Aug 6, 2024

本地测了一下挺好的 建议合并

Copy link

codecov bot commented Aug 6, 2024

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 1.30%. Comparing base (c936198) to head (816f5fc).

Files Patch % Lines
relay/adaptor/ollama/main.go 0.00% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##            main   #1694      +/-   ##
========================================
- Coverage   1.30%   1.30%   -0.01%     
========================================
  Files        144     144              
  Lines      10140   10143       +3     
========================================
  Hits         132     132              
- Misses      9994    9997       +3     
  Partials      14      14              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@songquanpeng songquanpeng changed the title Add Max Tokens and Context Window Setting Options for Ollama Channel feat: add Max Tokens and Context Window Setting Options for Ollama Channel Aug 6, 2024
@songquanpeng songquanpeng merged commit 04bb3ef into songquanpeng:main Aug 6, 2024
2 of 4 checks passed
@songquanpeng
Copy link
Owner

Thx~

mxdlzg pushed a commit to mxdlzg/one-api that referenced this pull request Oct 15, 2024
…annel (songquanpeng#1694)

* Update main.go with max_tokens param

* Update model.go with max_tokens param

* Update model.go

* Update main.go

* Update main.go

* Adds num_ctx param for Ollama Channel

* Added num_ctx param for ollama adapter

* Added num_ctx param for ollama adapter

* Improved data process logic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

为Ollama渠道添加context window和max tokens相关Options参数
4 participants