Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Oct 15, 2025

Summary by CodeRabbit

  • New Features
    • Expanded output formatting: accept either “json” or a custom JSON schema; more nullable options for flexibility.
    • New chat controls: think level (boolean or high/medium/low), truncate, and shift.
    • Federated model metadata: responses and model info now include remote model and host details.
    • Tooling improvements: tool call ordering via index fields; messages from tools can include a tool name.
    • Model creation enhancements: modelfile no longer required; added options for source, files, adapters, template, system, and parameters.

@HavenDV HavenDV enabled auto-merge (squash) October 15, 2025 18:38
@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Expanded OpenAPI schemas in src/libs/Ollama/openapi.yaml: added nullable and oneOf options for request fields, introduced think/truncate/shift controls, made CreateModelRequest.modelfile optional, added remote_model/remote_host metadata across responses and model schemas, and added index/tool_name fields to tool-related structures.

Changes

Cohort / File(s) Summary of Edits
Completion request schema updates
src/libs/Ollama/openapi.yaml
GenerateCompletionRequest: format changed to oneOf (json enum or JSON schema object) and nullable; keep_alive made nullable.
Chat request controls
src/libs/Ollama/openapi.yaml
GenerateChatCompletionRequest: added think (oneOf boolean or enum: high/medium/low, nullable), truncate (nullable boolean), shift (nullable boolean).
Response metadata (remote/federated)
src/libs/Ollama/openapi.yaml
GenerateCompletionResponse and GenerateChatCompletionResponse: added remote_model and remote_host (nullable strings).
Tooling schema enhancements
src/libs/Ollama/openapi.yaml
Message: added tool_name (nullable). ToolCallFunctionArgs and ToolCallFunction: added index (integer) to preserve call ordering.
Model creation flexibility
src/libs/Ollama/openapi.yaml
CreateModelRequest: modelfile moved to optional nullable property; added optional from, files, adapters, template, system, parameters (all nullable where applicable); removed modelfile from required.
Model and model info metadata
src/libs/Ollama/openapi.yaml
Model and ModelInfo-related schemas: added remote_model and remote_host (nullable) to expose upstream/federated source details.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant API as Ollama API
  participant RM as Remote Model (optional)

  rect rgb(240,248,255)
  note over C,API: Chat completion with think/truncate/shift controls
  C->>API: POST /chat/completions {think, truncate?, shift?, format?}
  alt think=true or level
    API->>API: Enable reasoning mode (per level)
  else think unset/false
    API->>API: Standard generation
  end
  opt shift=true
    API->>API: Adjust context window (shift)
  end
  opt format=json or JSON Schema
    API->>API: Constrain output to format/schema
  end
  end

  rect rgb(245,255,240)
  alt remote_model configured
    API->>RM: Proxy/route request
    RM-->>API: Generated content + metadata
    API-->>C: Response {remote_model, remote_host}
  else local model
    API-->>C: Response {remote_model: null, remote_host: null}
  end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my whiskers at schemas grown,
New knobs—think, shift—now finely shown.
A hint of JSON in tidy attire,
Remote trails mapped with upstream wire.
Tools lined up, each index neat—
Hippity-hop, specs feel complete! 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title “feat:@coderabbitai” does not describe any actual changes to the OpenAPI schemas or added features, and it fails to summarize the main modifications in the pull request. It uses a “feat:” prefix and a tag with no clear meaning, offering no context about the schema updates or new optional fields. As a result, it is misleading and does not help teammates understand the purpose of this PR. Please update the title to clearly reflect the core changes, for example “feat(openapi): add nullable fields and remote_model metadata to schemas” so that it succinctly conveys the key updates to the API specification.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202510151837

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 and usage tips.

@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:OpenAPI updates: nullable/oneOf, think/truncate/shift, remote metadata Oct 15, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/libs/Ollama/openapi.yaml (4)

313-330: Unify think/truncate/shift and clarify behavior when combined

  • Extract a shared components schema (e.g., ThinkOption) and reference it in both request types.
  • Document precedence: when truncate and shift are both true, which applies first? What happens on overflow?

Proposed shared schema (add under components.schemas):

ThinkOption:
  oneOf:
    - type: boolean
    - type: string
      enum: [high, medium, low]
  description: Controls thinking behavior.

Then replace think with:

think:
  $ref: '#/components/schemas/ThinkOption'
  nullable: true

Please also add a short note in each description clarifying truncate vs shift precedence.

Also applies to: 594-611


716-719: Tool messages: consider making tool_name required when role = "tool"

OAS 3.0 can’t express conditional required directly; you can approximate with oneOf variants (tool vs non-tool) or keep as-is and document it clearly.


769-772: index placement: put index on ToolCall (list element), not ToolCallFunction; summary inconsistency

  • The description says “index of the tool call in the list of tool calls”, so it belongs to ToolCall, not ToolCallFunction.
  • AI summary mentions ToolCallFunctionArgs.index was added, but it’s not present in code.

Apply these diffs:

@@ components.schemas.ToolCall.properties
       function:
         $ref: '#/components/schemas/ToolCallFunction'
+      index:
+        type: integer
+        description: The index of the tool call in the list of tool calls
@@ components.schemas.ToolCallFunction.properties
-        index:
-          type: integer
-          description: The index of the tool call in the list of tool calls

If you do need per-argument indexing, add it under ToolCallFunctionArgs with a clear description; otherwise omit to avoid confusion.

Also applies to: 774-776


289-299: Deduplicate format schema via $ref
Replace the inline oneOf in both GenerateCompletionRequest.properties.format and GenerateChatCompletionRequest.properties.format with an allOf pointing to #/components/schemas/ResponseFormat, preserving nullable and simplifying the description.

@@ components.schemas.GenerateCompletionRequest.properties
-        format:
-          oneOf:
-            - enum:
-                - json
-              type: string
-              description: Enable JSON mode
-              default: json
-            - type: object
-              description: JSON schema object for structured output validation
-          description: "The format to return a response in. Can be:\n- \"json\" string to enable JSON mode\n- JSON schema object for structured output validation\n"
-          nullable: true
+        format:
+          allOf:
+            - $ref: '#/components/schemas/ResponseFormat'
+          nullable: true
+          description: "The format to return a response in."
@@ components.schemas.GenerateChatCompletionRequest.properties
-        format:
-          oneOf:
-            - enum:
-                - json
-              type: string
-              description: Enable JSON mode
-              default: json
-            - type: object
-              description: JSON schema object for structured output validation
-          description: "The format to return a response in. Can be:\n- \"json\" string to enable JSON mode\n- JSON schema object for structured output validation\n"
-          nullable: true
+        format:
+          allOf:
+            - $ref: '#/components/schemas/ResponseFormat'
+          nullable: true
+          description: "The format to return a response in."
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b176606 and 574174b.

⛔ Files ignored due to path filters (42)
  • src/libs/Ollama/Generated/Ollama..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.ChatClient.GenerateChatCompletion.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.CompletionsClient.GenerateCompletion.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.IChatClient.GenerateChatCompletion.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.ICompletionsClient.GenerateCompletion.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.IModelsClient.CreateModel.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateChatCompletionRequestFormatEnum.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateChatCompletionRequestFormatEnumNullable.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateChatCompletionRequestThink.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateChatCompletionRequestThinkNullable.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateCompletionRequestFormatEnum.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateCompletionRequestFormatEnumNullable.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateCompletionRequestThink.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.GenerateCompletionRequestThinkNullable.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonConverters.OneOf2.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequest.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequestAdapters.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequestAdapters.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequestFiles.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequestFiles.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequestParameters.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.CreateModelRequestParameters.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateChatCompletionRequest.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateChatCompletionRequestFormatEnum.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateChatCompletionRequestFormatEnum2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateChatCompletionRequestFormatEnum2.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateChatCompletionRequestThink.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateChatCompletionResponse.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateCompletionRequest.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateCompletionRequestFormatEnum.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateCompletionRequestFormatEnum2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateCompletionRequestFormatEnum2.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateCompletionRequestThink.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.GenerateCompletionResponse.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.Message.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.Model.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.ModelInfo.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.Models.ToolCallFunction.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/Ollama.ModelsClient.CreateModel.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/OneOf.2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Ollama/Generated/OneOf.2.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Ollama/openapi.yaml (12 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test / Build, test and publish
🔇 Additional comments (2)
src/libs/Ollama/openapi.yaml (2)

823-823: Make modelfile optional: LGTM

This aligns with remote create and blob-based workflows.


836-840: Avoid reserved property name from
Rename the property to source (or from_model) to prevent codegen issues in languages where from is reserved (Python, C#, Kotlin).

-        from:
+        source:

If renaming isn’t feasible now, document this in README/SDKs and validate with common generators.

Comment on lines +543 to 551
remote_model:
type: string
description: Name of the upstream remote model that generated the response (when using federated models)
nullable: true
remote_host:
type: string
description: URL of the upstream Ollama host that served the request (when proxying to remote instances)
nullable: true
description: The response class for the generate endpoint.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

🧩 Analysis chain

Potential leakage of internal hostnames via remote_host; mark readOnly and consider redaction

Exposing remote_host may leak internal topology. Mark fields readOnly and consider returning sanitized hostnames or omit by default.

Apply readOnly to all remote_* fields:

@@ components.schemas.GenerateCompletionResponse.properties
         remote_model:
           type: string
           description: Name of the upstream remote model that generated the response (when using federated models)
           nullable: true
+          readOnly: true
         remote_host:
           type: string
           description: URL of the upstream Ollama host that served the request (when proxying to remote instances)
           nullable: true
+          readOnly: true
@@ components.schemas.GenerateChatCompletionResponse.properties
         remote_model:
           type: string
           description: Name of the upstream remote model that generated the response (when using federated models)
           nullable: true
+          readOnly: true
         remote_host:
           type: string
           description: URL of the upstream Ollama host that served the request (when proxying to remote instances)
           nullable: true
+          readOnly: true
@@ components.schemas.Model.properties
         remote_model:
           type: string
           description: Name of the upstream remote model (when model is federated from another Ollama instance)
           nullable: true
+          readOnly: true
         remote_host:
           type: string
           description: URL of the upstream Ollama host (when model is federated from another instance)
           nullable: true
+          readOnly: true
@@ components.schemas.ModelInfo.properties
         remote_model:
           type: string
           description: Name of the upstream remote model (when model is federated from another Ollama instance)
           nullable: true
+          readOnly: true
         remote_host:
           type: string
           description: URL of the upstream Ollama host (when model is federated from another instance)
           nullable: true
+          readOnly: true

Also confirm these are not logged or echoed back to multi-tenant clients by default.

Also applies to: 665-673, 912-920, 1095-1102


🏁 Script executed:

#!/bin/bash
# Locate the OpenAPI spec file
fd --hidden --ignore-case openapi.yaml

# Inspect GenerateCompletionResponse around lines 543-551
sed -n '530,580p' src/libs/Ollama/openapi.yaml

# Inspect GenerateChatCompletionResponse around lines 665-673
sed -n '650,700p' src/libs/Ollama/openapi.yaml

# Inspect Model schema around lines 912-920
sed -n '900,950p' src/libs/Ollama/openapi.yaml

# Inspect ModelInfo schema around lines 1095-1102
sed -n '1080,1120p' src/libs/Ollama/openapi.yaml

Length of output: 6940


🏁 Script executed:

#!/bin/bash
grep -R "GenerateChatCompletionResponse" -n src/libs/Ollama/openapi.yaml || echo "Not found"

Length of output: 118


🏁 Script executed:

#!/bin/bash
# Inspect GenerateChatCompletionResponse around its definition
sed -n '595,650p' src/libs/Ollama/openapi.yaml
# Search for a 'Model' component schema
grep -nP "^[[:space:]]*Model:$" src/libs/Ollama/openapi.yaml || echo "Model schema not found"

Length of output: 2190


🏁 Script executed:

#!/bin/bash
# Inspect 'Model' schema around its definition
sed -n '880,940p' src/libs/Ollama/openapi.yaml

# Inspect 'ModelInformation' schema around its definition
sed -n '940,1020p' src/libs/Ollama/openapi.yaml

Length of output: 4780


🏁 Script executed:

#!/bin/bash
# List all occurrences of remote_model for context
grep -R -n "remote_model:" src/libs/Ollama/openapi.yaml

# Inspect GenerateChatCompletionResponse for remote fields
sed -n '650,740p' src/libs/Ollama/openapi.yaml

Length of output: 3209


Add readOnly to actual remote_ fields*
The remote_model and remote_host properties exist in these schemas—GenerateCompletionResponse, GenerateChatCompletionRequest, Message, and Model—and should include

readOnly: true

Also sanitize or omit remote_host by default to avoid leaking internal hostnames.

🤖 Prompt for AI Agents
In src/libs/Ollama/openapi.yaml around lines 543 to 551, the remote_model and
remote_host properties must be marked as response-only and not client-settable:
add "readOnly: true" to both properties in all affected schemas
(GenerateCompletionResponse, GenerateChatCompletionRequest, Message, and Model)
so they are documented as server-generated; additionally sanitize or omit
remote_host by default to avoid leaking internal hostnames — either remove it
from default responses or set it to null/empty by default and ensure any
returned value is sanitized (no internal hostnames) before emitting.

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.

2 participants