Skip to content

feat(ollama): passthrough Claude Messages and OpenAI Responses - #7051

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/native-ollama
Aug 27, 2026
Merged

feat(ollama): passthrough Claude Messages and OpenAI Responses#7051
seefs001 merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/native-ollama

Conversation

@seefs001

@seefs001 seefs001 commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)

Ollama渠道类型 支持原生 /v1/messages 和 /v1/responses

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • New Features

    • Added support for Claude-format requests through the Ollama integration.
    • Added support for OpenAI Responses requests.
    • Added handling for embeddings and compact Responses modes.
    • Improved request routing based on the selected relay mode.
  • Bug Fixes

    • Responses requests no longer return an unsupported-operation error.
    • Response handling now correctly supports additional request formats and modes.

@seefs001
seefs001 merged commit ba2e928 into QuantumNous:main Aug 27, 2026
3 of 4 checks passed
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5474b190-c959-448b-8a6f-bcd213920334

📥 Commits

Reviewing files that changed from the base of the PR and between cae3676 and 24e4f34.

📒 Files selected for processing (1)
  • relay/channel/ollama/adaptor.go

Walkthrough

The Ollama adaptor now supports Claude-format requests, OpenAI Responses requests, embeddings, Responses modes, and explicit relay-mode URL selection. Claude headers and response handling now use the Claude adaptor.

Changes

Ollama protocol support

Layer / File(s) Summary
Request routing and conversion
relay/channel/ollama/adaptor.go
The adaptor delegates Claude conversion, selects URLs by RelayMode, applies Claude headers, selects chat or generate conversion, and delegates OpenAI Responses conversion.
Format-specific response dispatch
relay/channel/ollama/adaptor.go
DoResponse dispatches Claude, embeddings, Responses, compact Responses, and default stream or chat responses to the corresponding handlers.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant OllamaAdaptor
  participant ClaudeAdaptor
  participant OpenAIAdaptor
  participant OllamaAPI
  Client->>OllamaAdaptor: Submit relay request
  alt Claude format
    OllamaAdaptor->>ClaudeAdaptor: Convert request and configure URL
    OllamaAdaptor->>ClaudeAdaptor: Apply headers
  else OpenAI Responses mode
    OllamaAdaptor->>OpenAIAdaptor: Convert request
  else Other relay modes
    OllamaAdaptor->>OllamaAdaptor: Select mode-specific URL and conversion
  end
  OllamaAdaptor->>OllamaAPI: Send converted request
  OllamaAPI-->>OllamaAdaptor: Return response
  alt Claude format
    OllamaAdaptor->>ClaudeAdaptor: Handle response
  else Responses modes
    OllamaAdaptor->>OpenAIAdaptor: Handle response
  else Embeddings mode
    OllamaAdaptor->>OllamaAdaptor: Handle embedding response
  else Other modes
    OllamaAdaptor->>OllamaAdaptor: Handle stream or chat response
  end
Loading

Suggested reviewers: calcium-ion

Poem

A rabbit hops through routes anew
Claude and Responses join the queue
Headers bloom, modes guide the way
Embeddings answer without delay
Streams and chats return in tune

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

mrdjango added a commit to mrdjango/models-gateway that referenced this pull request Aug 28, 2026
* feat: glm chanel /v1/responses (QuantumNous#7050)

* feat(ollama): passthrough Claude Messages and OpenAI Responses (QuantumNous#7051)

* docs: update PR template and remove PR Check workflow (QuantumNous#7053)

* docs: update PR template and remove PR Check workflow

* docs: add hidden agent issue and PR templates

---------

Co-authored-by: Seefs <40468931+seefs001@users.noreply.github.com>
mrdjango added a commit to mrdjango/models-gateway that referenced this pull request Aug 29, 2026
* feat: glm chanel /v1/responses (QuantumNous#7050)

* feat(ollama): passthrough Claude Messages and OpenAI Responses (QuantumNous#7051)

* docs: update PR template and remove PR Check workflow (QuantumNous#7053)

* docs: update PR template and remove PR Check workflow

* docs: add hidden agent issue and PR templates

* fix(web): restore admin unbinding for built-in providers (QuantumNous#6987)

* fix(web): align admin binding types

Refs QuantumNous#6985

* test(web): restore animation mock

* fix(billing): 修复时间规则恒真表达式导致倍率全天生效 (QuantumNous#6934)


Co-authored-by: seefs001 <i@seefs.me>

* fix(docker): add relaykit go.mod to dev build context (QuantumNous#7072)

* feat(task): replace built-in task adaptors with a sandboxed JS plugin system (QuantumNous#7076)

* fix(relay): 请求参数校验错误返回 HTTP 400 (QuantumNous#6774)

* fix(relay): return 400 for invalid request parameters

* fix(web): recheck setup status after page reload (QuantumNous#6968)

* feat(auth): encrypt password login transport

Closes QuantumNous#6743

---------

Co-authored-by: Seefs <40468931+seefs001@users.noreply.github.com>
Co-authored-by: zcxads666 <128150298+zcxads666@users.noreply.github.com>
Co-authored-by: seefs001 <i@seefs.me>
Co-authored-by: Uladzislau <53997152+VladKabiak@users.noreply.github.com>
Co-authored-by: Calcium-Ion <i@caion.me>
Co-authored-by: Alex Xiang <ax2@zicode.com>
nanashiwang pushed a commit to nanashiwang/new-api that referenced this pull request Aug 29, 2026
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.

claude code 接入 ollama 的时候 会报错 Unable to validate model: undefined is not an object (evaluating 'U.usage.input_tokens')

1 participant