Skip to content

Add Gemini-to-OpenAI Chat compatibility helpers, tests, and CI job#1

Merged
hungvminh merged 1 commit into
masterfrom
codex/convert-gemini-cli-to-chatgpt-api
May 25, 2026
Merged

Add Gemini-to-OpenAI Chat compatibility helpers, tests, and CI job#1
hungvminh merged 1 commit into
masterfrom
codex/convert-gemini-cli-to-chatgpt-api

Conversation

@hungvminh

Copy link
Copy Markdown
Owner

Motivation

  • Provide a small compatibility layer to translate Gemini-style generate responses to OpenAI Chat Completions shapes for easier integration.
  • Make the conversion deterministic for downstream code by normalizing message roles, parts, and finish reasons.
  • Run and enforce the compatibility tests in CI to catch regressions early.

Description

  • Added a new helper module at server/src/modules/common/geminiChatCompat.ts that exposes toGeminiContents(messages) and toOpenAIChatCompletion(geminiResponse, model, id?) and relevant types.
  • Implemented finish-reason normalization mapping Gemini finish reasons (STOP, MAX_TOKENS, SAFETY) to OpenAI-style reasons (stop, length, content_filter).
  • Added unit-style assertions in server/src/modules/common/geminiChatCompat.test.ts that validate conversions and usage/choice shaping.
  • Updated server/package.json with a test:gemini-compat script and documented the helper in README.md, and added a GitHub Actions workflow .github/workflows/ci.yml to run the test under node 20.

Testing

  • Ran the new automated test via npm run test:gemini-compat in the server package and the assertions completed successfully.
  • The CI workflow gemini-compat-tests was added to execute the same npm run test:gemini-compat step on ubuntu-latest with Node.js 20.
  • The test file logs geminiChatCompat tests passed on success and uses built-in assert checks to validate conversions.

Codex Task

@hungvminh hungvminh merged commit 80c5801 into master May 25, 2026
0 of 2 checks passed
@hungvminh hungvminh deleted the codex/convert-gemini-cli-to-chatgpt-api branch May 25, 2026 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant