Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Apr 24, 2025

Summary by CodeRabbit

  • New Features

    • Introduced an endpoint to evaluate the factual consistency of generated text against source documents, returning a hallucination likelihood score.
    • Added an OpenAI-compatible chat completion endpoint supporting streaming responses for conversational AI use cases.
  • Improvements

    • Enhanced table extraction configuration with new options for table summarization using customizable generation parameters.
    • Clarified and updated endpoint descriptions and documentation for improved usability.

@coderabbitai
Copy link

coderabbitai bot commented Apr 24, 2025

Walkthrough

The OpenAPI specification for the Vectara REST API v2 was updated to introduce two new endpoints: one for evaluating the factual consistency of generated text and another for OpenAI-compatible LLM chat completions, including streaming support. Several new request and response schemas were added to support these endpoints. Enhancements were made to table extraction configuration by integrating a new table generation specification. Descriptions and formatting were refined for clarity, including updates to existing endpoint documentation and schema properties.

Changes

File(s) Change Summary
src/libs/Vectara/openapi.yaml Added new POST endpoints /v2/evaluate_factual_consistency and /v2/llms/chat/completions with corresponding schemas for requests and responses. Enhanced table extraction configuration with TableGenerationSpec. Updated descriptions and formatting for clarity. Added new tags for LLM chat completions and factual consistency evaluation.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API

    %% Factual Consistency Evaluation
    Client->>API: POST /v2/evaluate_factual_consistency (generated_text, source_texts)
    API-->>Client: { score: 0.0 - 1.0 }

    %% LLM Chat Completion
    Client->>API: POST /v2/llms/chat/completions (model, messages)
    alt Streaming enabled
        API-->>Client: SSE stream of chat completion chunks
    else Non-streaming
        API-->>Client: Full chat completion response
    end
Loading

Poem

In the warren where APIs grow,
New endpoints pop up, in a tidy row—
Chatting with LLMs, facts checked anew,
Table specs sparkle, descriptions too!
With every schema, the docs hop ahead,
A carrot for clarity, and bugs put to bed.
🐇✨


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.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai 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:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @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

Documentation and Community

  • 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 merged commit 9fdc6ca into main Apr 24, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202504240633 branch April 24, 2025 06:34
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Add endpoints for factual consistency evaluation and OpenAI-compatible chat completions Apr 24, 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: 3

🧹 Nitpick comments (10)
src/libs/Vectara/openapi.yaml (10)

1651-1693: Add examples and refine error cases for factual consistency endpoint
The new /v2/evaluate_factual_consistency endpoint and its schemas align with the PR objectives. To improve usability, add x-fern-examples for both request and response, and consider documenting the 422 error in the components (e.g., an UnsupportedLanguageError).


4655-4672: Refine TableGenerationSpec schema for stricter validation
Currently all fields in TableGenerationSpec are optional. Consider adding minProperties: 1 or marking llm_name or prompt_template as required to prevent empty objects. Also, explicitly define model_parameters shape rather than a free‐form object for better tooling support.


3949-3984: Add examples and tighten validation for factual consistency schemas
Both EvaluateFactualConsistencyRequest and EvaluateFactualConsistencyResponse are defined correctly. To improve discoverability, add example blocks for generated_text, source_texts, and score, and enforce minItems: 1 on source_texts and a non-empty constraint on generated_text.


4102-4107: Enhance documentation for custom headers in OpenAI LLM requests
The new headers property enables custom HTTP headers. Suggest providing an example of setting a user-agent or organization header in x-fern-examples, and clarifying allowed header names/values.


5339-5355: Encourage role enumeration in ChatCompletionRequestMessage
The new message object captures role, content, and optional name. For clarity, consider enumerating allowed roles (system, user, assistant, etc.) in the schema and adding a sample message under x-fern-examples.


5356-5372: Consider adding usage metrics to chat completion response
The response currently returns object and choices. To align with OpenAI’s interface, consider including an optional usage object (tokens used) in CreateChatCompletionResponse.


5373-5383: Augment ChatCompletionResponseChoice with finish_reason
OpenAI’s chat API includes finish_reason in each choice. To support similar client behavior, consider adding finish_reason (e.g., stop, length) to the schema.


5394-5410: Improve streaming response schema for chat completions
CreateChatCompletionStreamResponse correctly defines SSE chunks, but consider adding comments about the SSE framing (data: prefix) or including an example in the spec.


5286-5286: Align request_id description in NotFoundError schema
You’ve added a custom description for request_id. Ensure it matches wording in BadRequestError and the general Error schema to maintain consistency across all error types.


5497-5497: Add newline at end-of-file
YAML files should end with a single newline character to satisfy POSIX standards and tooling (YAMLLint).

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 5497-5497: no new line character at the end of file

(new-line-at-end-of-file)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3cd8806 and 57337b2.

⛔ Files ignored due to path filters (53)
  • src/libs/Vectara/Generated/JsonConverters.CreateChatCompletionResponseObject.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/JsonConverters.CreateChatCompletionResponseObjectNullable.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/JsonConverters.CreateChatCompletionStreamResponseObject.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/JsonConverters.CreateChatCompletionStreamResponseObjectNullable.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.FactualConsistencyEvaluationClient.EvaluateFactualConsistency.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.FactualConsistencyEvaluationClient.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.IFactualConsistencyEvaluationClient.EvaluateFactualConsistency.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.IFactualConsistencyEvaluationClient.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.ILLMChatCompletionsClient.CreateChatCompletion.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.ILLMChatCompletionsClient.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.IUploadClient.UploadFile.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.IVectaraClient.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.LLMChatCompletionsClient.CreateChatCompletion.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.LLMChatCompletionsClient.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionRequestMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionRequestMessage.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionResponseChoice.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionResponseChoice.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionResponseMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionResponseMessage.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionStreamResponseChoice.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionStreamResponseChoice.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionStreamResponseDelta.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.ChatCompletionStreamResponseDelta.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionRequest.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionRequest.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionResponse.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionResponseObject.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionStreamResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionStreamResponse.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateChatCompletionStreamResponseObject.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateOpenAILLMRequest.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateOpenAILLMRequestHeaders.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.CreateOpenAILLMRequestHeaders.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.EvaluateFactualConsistencyRequest.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.EvaluateFactualConsistencyRequest.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.EvaluateFactualConsistencyRequestModelParameters.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.EvaluateFactualConsistencyRequestModelParameters.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.EvaluateFactualConsistencyResponse.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.EvaluateFactualConsistencyResponse.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.NotFoundError.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.TableExtractionConfig.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.TableExtractor.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.TableGenerationSpec.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.TableGenerationSpec.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.TableGenerationSpecModelParameters.Json.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.TableGenerationSpecModelParameters.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.Models.UploadFileRequest.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.UploadClient.UploadFile.g.cs is excluded by !**/generated/**
  • src/libs/Vectara/Generated/Vectara.VectaraClient.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Vectara/openapi.yaml (11 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
src/libs/Vectara/openapi.yaml

[error] 5497-5497: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (6)
src/libs/Vectara/openapi.yaml (6)

560-560: Clarify optional parameters in file upload endpoint
The updated description correctly emphasizes that metadata, chunking_strategy, and table_extraction_config are only applied if provided (with defaults otherwise). Consider adding a short example to illustrate default behavior when those parts are omitted.


2720-2761: Ensure consistent streaming metadata for chat completions
The /v2/llms/chat/completions endpoint now supports streaming via SSE, but the metadata uses x-stream-based-on-body: stream() while other endpoints use streamResponse() or streamResponse(). Confirm that tooling and SDKs correctly interpret this pattern, or harmonize to a single convention. Also add a realistic example under x-fern-examples.


3647-3649: Approve addition of generation to TableExtractionConfig
Introducing the optional generation property to TableExtractionConfig allows downstream summarization control. This change is aligned with the new TableGenerationSpec.


4686-4688: Approve addition of generation to TableExtractor
Adding the optional generation reference in TableExtractor aligns with the extended table-extraction configuration. Verify SDK codegen picks up this new property.


5319-5339: Verify naming consistency for streaming flag in chat completion request
The schema uses stream (default: false), whereas other endpoints use stream_response. Ensure downstream SDKs and documentation correctly reference stream; if possible, align naming for consistency with the rest of the API.


5493-5496: Approve new OpenAPI tags for Table Extractors and chat features
The addition of LLM Chat Completions and Factual Consistency Evaluation tags (along with updating Table Extractors) properly categorizes the new endpoints.

Comment on lines +5411 to +5421
required:
- index
- delta
type: object
properties:
index:
type: integer
description: The index of the choice in the array of choices.
delta:
$ref: '#/components/schemas/ChatCompletionStreamResponseDelta'
description: A single chat completion chunk choice in a streaming response.
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Missing delta.content in streaming choice schema
ChatCompletionStreamResponseChoice’s delta currently only supports role. Streaming partial messages require a content field.

Add:

 properties:
   delta:
     $ref: '#/components/schemas/ChatCompletionStreamResponseDelta'
+    # ensure content is allowed in delta

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +5423 to 5429
type: object
properties:
role:
type: string
description: 'The role of the author of this message, typically ''assistant'' for responses.'
description: A partial message update to be merged with previous chunks in a streaming response.
parameters:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Define content in ChatCompletionStreamResponseDelta
The delta schema only allows role. Streaming deltas need a content string property (and possibly function_call fields).

Add:

 properties:
   role:
     type: string
+  content:
+    type: string
+    description: Partial content chunk from the assistant.
📝 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
type: object
properties:
role:
type: string
description: 'The role of the author of this message, typically ''assistant'' for responses.'
description: A partial message update to be merged with previous chunks in a streaming response.
parameters:
type: object
properties:
role:
type: string
description: 'The role of the author of this message, typically ''assistant'' for responses.'
content:
type: string
description: Partial content chunk from the assistant.
description: A partial message update to be merged with previous chunks in a streaming response.
parameters:

Comment on lines +5384 to +5393
ChatCompletionResponseMessage:
required:
- role
type: object
properties:
role:
type: string
description: 'The role of the author of this message, typically ''assistant'' for responses.'
description: A message in the chat completion response from the assistant.
CreateChatCompletionStreamResponse:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical: Missing content in response message schema
ChatCompletionResponseMessage only defines role but omits the required content property, which will break deserialization of assistant replies.

Add:

 properties:
   role:
     type: string
-    # missing content
+  content:
+    type: string
+    description: The content of the assistant’s message.

Committable suggestion skipped: line range outside the PR's diff.

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