Skip to content

Commit 593092e

Browse files
cuipengfeiclaude
andcommitted
Merge feature/gemini-api branch
Resolves merge conflicts and integrates: - Complete Gemini API translation layer - Streaming and non-streaming endpoints - Tool call accumulator for fragmented responses - GitHub Actions test fix with query string imports - Header mode configuration - Debug logging improvements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
2 parents 0486fd8 + 8f21b6e commit 593092e

4 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/routes/generate-content/translation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ export function translateOpenAIToGemini(
536536
},
537537
}
538538

539-
// Debug: Log original GitHub Copilot response and translated Gemini response for comparison
539+
// Debug: Log original GitHub Copilot response and translated Gemini response
540540
if (process.env.DEBUG_GEMINI_REQUESTS === "true") {
541541
DebugLogger.logResponseComparison(response, result, {
542542
context: "Non-Stream Response Translation",

src/server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ server.route("/token", tokenRoute)
2727
server.route("/v1/chat/completions", completionRoutes)
2828
server.route("/v1/models", modelRoutes)
2929
server.route("/v1/embeddings", embeddingRoutes)
30+
server.route("/", geminiRouter)
3031

3132
// Anthropic compatible endpoints
3233
server.route("/v1/messages", messageRoutes)

src/start.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,11 @@ export async function runServer(options: RunServerOptions): Promise<void> {
125125
consola.box(
126126
`🌐 Usage Viewer: https://ericc-ch.github.io/copilot-api?endpoint=${serverUrl}/usage`,
127127
)
128-
129128
serve({
130129
fetch: server.fetch as ServerHandler,
131130
port: options.port,
132131
bun: {
133-
idleTimeout: 255,
132+
idleTimeout: 255, // gemini timeout
134133
},
135134
})
136135
}

tests/generate-content/streaming.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ test("falls back to streaming when downstream returns non-stream JSON", async ()
2727
}),
2828
}))
2929

30-
const { server } = (await import("~/server")) as { server: TestServer }
30+
await createMockRateLimit()
31+
const { server } = (await import("~/server?fallback-non-streaming")) as {
32+
server: TestServer
33+
}
3134
const res = await server.request(
3235
"/v1beta/models/gemini-pro:streamGenerateContent",
3336
{

0 commit comments

Comments
 (0)