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
Prev Previous commit
Improved data process logic
MotorBottle authored Jul 26, 2024
commit 816f5fc9f61f4aaaf8236ad1fb89354a0fc9323a
3 changes: 3 additions & 0 deletions relay/adaptor/ollama/main.go
Original file line number Diff line number Diff line change
@@ -31,8 +31,8 @@
TopP: request.TopP,
FrequencyPenalty: request.FrequencyPenalty,
PresencePenalty: request.PresencePenalty,
NumPredict: request.MaxTokens,
NumCtx: request.NumCtx,

Check warning on line 35 in relay/adaptor/ollama/main.go

Codecov / codecov/patch

relay/adaptor/ollama/main.go#L34-L35

Added lines #L34 - L35 were not covered by tests
},
Stream: request.Stream,
}
@@ -120,7 +120,10 @@
common.SetEventStreamHeaders(c)

for scanner.Scan() {
data := scanner.Text()
if strings.HasPrefix(data, "}") {
data = strings.TrimPrefix(data, "}") + "}"

Check warning on line 125 in relay/adaptor/ollama/main.go

Codecov / codecov/patch

relay/adaptor/ollama/main.go#L123-L125

Added lines #L123 - L125 were not covered by tests
}

var ollamaResponse ChatResponse
err := json.Unmarshal([]byte(data), &ollamaResponse)