Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Aug 29, 2025

Summary by CodeRabbit

  • New Features
    • Richer model metadata now available in responses, including description, context limits, pricing, and tags.
    • Prompts can be provided as raw token IDs in completions and model calls, in addition to text.
    • Embeddings endpoint accepts multiple inputs at once (string or list of strings).
    • Control generation with stop token IDs.
    • Option to receive outputs as token IDs instead of text.

@coderabbitai
Copy link

coderabbitai bot commented Aug 29, 2025

Walkthrough

Introduces a new ModelMetadata schema and exposes it via OpenAIModelOut.metadata. Expands prompt/input types to accept strings or token ID arrays in multiple schemas. Extends OpenAIEmbeddingsIn with stop_token_ids and return_tokens_as_token_ids. All changes are within src/libs/DeepInfra/openapi.yaml.

Changes

Cohort / File(s) Summary
Metadata schema exposure
src/libs/DeepInfra/openapi.yaml
Added public ModelMetadata schema; added OpenAIModelOut.metadata: ModelMetadata.
Token-id prompt support
src/libs/DeepInfra/openapi.yaml
Changed ModelOut.prompt and OpenAICompletionsIn.prompt to anyOf string or array of integers.
Embeddings input expansion
src/libs/DeepInfra/openapi.yaml
OpenAIEmbeddingsIn.input now accepts string or array of strings; added stop_token_ids (array of integers) and return_tokens_as_token_ids (boolean).

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant API as DeepInfra API
  participant Model as Model Runtime

  rect rgba(230,245,255,0.5)
    note over Client,API: Completions/Model invocation with flexible prompt
    Client->>API: POST /... (prompt: string | [int])
    API->>Model: Normalize prompt (text or token IDs)
    alt prompt is [int]
      note right of API: Skip tokenization
    else prompt is string
      API->>Model: Tokenize text
    end
    Model-->>API: Generated output (text or token IDs per request)
    API-->>Client: Response (may include metadata)
  end

  rect rgba(240,255,230,0.5)
    note over Client,API: Embeddings with expanded inputs
    Client->>API: POST /embeddings (input: string | [string], stop_token_ids?, return_tokens_as_token_ids?)
    API->>Model: Compute embeddings with stop controls
    Model-->>API: Embeddings (and optional token IDs)
    API-->>Client: Embeddings response
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

A rabbit taps on YAML fields,
New metadata softly yields.
Tokens hop as IDs or strings,
Embeddings sprout with stopping springs.
Return them raw, the tokens gleam—
Schemas trimmed, a tidier stream. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot/update-openapi_202508290125

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbit in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbit in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbit gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbit read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbit help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbit ignore or @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbit summary or @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbit or @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@HavenDV HavenDV enabled auto-merge (squash) August 29, 2025 01:26
@HavenDV HavenDV merged commit a76c706 into main Aug 29, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202508290125 branch August 29, 2025 01:28
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add ModelMetadata, allow string or token ID inputs, extend Embeddings Aug 29, 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: 2

🧹 Nitpick comments (1)
src/libs/DeepInfra/openapi.yaml (1)

7678-7680: Make metadata explicitly nullable and document it.

This keeps OpenAIModelOut backward-compatible when metadata is absent.

Apply:

         metadata:
-          $ref: '#/components/schemas/ModelMetadata'
+          $ref: '#/components/schemas/ModelMetadata'
+          nullable: true
+          description: Optional model metadata (present for models where this information is available).
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 6dbab35 and 87eb0fd.

⛔ Files ignored due to path filters (12)
  • src/libs/DeepInfra/Generated/DeepInfra..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.OpenaiCompletions.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.DeepInfraClient.OpenaiCompletions2.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.OpenaiCompletions.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.IDeepInfraClient.OpenaiCompletions2.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.ModelMetadata.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.ModelMetadata.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.ModelMetadataPricing.Json.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.ModelMetadataPricing.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.OpenAICompletionsIn.g.cs is excluded by !**/generated/**
  • src/libs/DeepInfra/Generated/DeepInfra.Models.OpenAIModelOut.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/DeepInfra/openapi.yaml (4 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 (1)
src/libs/DeepInfra/openapi.yaml (1)

7436-7447: Harden stop_token_ids schema – add minimum: 0 under items, uniqueItems: true, and update its description to note that when both stop (strings) and stop_token_ids are provided, generation will halt on the first matched token from either set. The OpenAPI v3.0.4 spec supports these keywords; please verify the server enforces this precedence.

Comment on lines +6766 to +6794
ModelMetadata:
title: ModelMetadata
required:
- description
- context_length
- max_tokens
- pricing
- tags
type: object
properties:
description:
title: Description
type: string
context_length:
title: Context Length
type: integer
max_tokens:
title: Max Tokens
type: integer
pricing:
title: Pricing
type: object
additionalProperties:
type: number
tags:
title: Tags
type: array
items:
type: string
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

ModelMetadata: add minimums and tighten collections.

  • context_length/max_tokens should be non-negative.
  • pricing benefits from a brief units description.
  • tags should avoid duplicates.

Apply:

     ModelMetadata:
       title: ModelMetadata
@@
         context_length:
           title: Context Length
           type: integer
+          minimum: 0
         max_tokens:
           title: Max Tokens
           type: integer
+          minimum: 0
         pricing:
           title: Pricing
           type: object
+          description: Map of pricing metrics (e.g., "prompt", "completion") to price per token in USD.
           additionalProperties:
             type: number
         tags:
           title: Tags
           type: array
+          uniqueItems: true
           items:
             type: string
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ModelMetadata:
title: ModelMetadata
required:
- description
- context_length
- max_tokens
- pricing
- tags
type: object
properties:
description:
title: Description
type: string
context_length:
title: Context Length
type: integer
max_tokens:
title: Max Tokens
type: integer
pricing:
title: Pricing
type: object
additionalProperties:
type: number
tags:
title: Tags
type: array
items:
type: string
ModelMetadata:
title: ModelMetadata
required:
- description
- context_length
- max_tokens
- pricing
- tags
type: object
properties:
description:
title: Description
type: string
context_length:
title: Context Length
type: integer
minimum: 0
max_tokens:
title: Max Tokens
type: integer
minimum: 0
pricing:
title: Pricing
type: object
description: Map of pricing metrics (e.g., "prompt", "completion") to price per token in USD.
additionalProperties:
type: number
tags:
title: Tags
type: array
uniqueItems: true
items:
type: string
🤖 Prompt for AI Agents
In src/libs/DeepInfra/openapi.yaml around lines 6766 to 6794, the ModelMetadata
schema needs tightening: add minimum: 0 to both context_length and max_tokens to
enforce non-negative integers; add a brief description on the pricing property
and its additionalProperties to document the units (e.g., price per token or per
1k tokens) while keeping additionalProperties as number; and set tags to include
uniqueItems: true to prevent duplicate tag entries. Make these changes in-place
within the ModelMetadata properties block.

Comment on lines +7322 to 7327
anyOf:
- type: string
- type: array
items:
type: integer
description: input prompt - a single string is currently supported
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Prompt now accepts token IDs: update description and add basic validation.

Align the description with the new anyOf and add simple bounds to avoid negative token IDs and empty arrays.

Apply:

         prompt:
           title: Prompt
-          anyOf:
+          anyOf:
             - type: string
             - type: array
-              items:
-                type: integer
-          description: input prompt - a single string is currently supported
+              minItems: 1
+              items:
+                type: integer
+                minimum: 0
+          description: Input prompt as text or as an array of token IDs.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
anyOf:
- type: string
- type: array
items:
type: integer
description: input prompt - a single string is currently supported
prompt:
title: Prompt
anyOf:
- type: string
- type: array
minItems: 1
items:
type: integer
minimum: 0
description: Input prompt as text or as an array of token IDs.
🤖 Prompt for AI Agents
In src/libs/DeepInfra/openapi.yaml around lines 7322 to 7327, the schema now
allows either a string or an array of integers but the description and
validation are out of date; update the description to state the prompt may be a
text string or an array of token IDs, and add basic validation on the array form
by adding minItems: 1 to prevent empty arrays and minimum: 0 on the integer
items to forbid negative token IDs; also add minLength: 1 to the string type to
prevent empty strings.

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