feat: gemini adapter with bidirectional translation incl streaming and embeddings

This commit is contained in:
2026-08-20 04:16:10 +01:00
parent 876d340054
commit 2891766b5f
48 changed files with 2463 additions and 7 deletions
+8
View File
@@ -0,0 +1,8 @@
{
"model": "gemini-2.5-pro",
"messages": [
{"role": "user", "content": "Hello there"}
],
"max_tokens": 256,
"temperature": 0.7
}
+9
View File
@@ -0,0 +1,9 @@
{
"contents": [
{"role": "user", "parts": [{"text": "Hello there"}]}
],
"generationConfig": {
"maxOutputTokens": 256,
"temperature": 0.7
}
}
+11
View File
@@ -0,0 +1,11 @@
{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "https://example.com/cat.png"}}
]
}
]
}
+1
View File
@@ -0,0 +1 @@
{"errContains": "must be a data: URI", "notSupported": false}
+12
View File
@@ -0,0 +1,12 @@
{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "data:image/jpeg;charset=utf-8;base64,/9j/4AAQSkZJRg=="}}
]
}
]
}
+11
View File
@@ -0,0 +1,11 @@
{
"contents": [
{
"role": "user",
"parts": [
{"text": "What is in this image?"},
{"inlineData": {"mimeType": "image/jpeg", "data": "/9j/4AAQSkZJRg=="}}
]
}
]
}
+16
View File
@@ -0,0 +1,16 @@
{
"model": "gemini-2.5-pro",
"messages": [
{"role": "user", "content": "What's the weather in Paris and Tokyo?"},
{
"role": "assistant",
"content": null,
"tool_calls": [
{"id": "call_1", "type": "function", "function": {"name": "get_weather", "arguments": "{\"location\":\"Paris\"}"}},
{"id": "call_2", "type": "function", "function": {"name": "get_weather", "arguments": "{\"location\":\"Tokyo\"}"}}
]
},
{"role": "tool", "tool_call_id": "call_1", "content": "{\"temp_c\":18}"},
{"role": "tool", "tool_call_id": "call_2", "content": "{\"temp_c\":27}"}
]
}
+19
View File
@@ -0,0 +1,19 @@
{
"contents": [
{"role": "user", "parts": [{"text": "What's the weather in Paris and Tokyo?"}]},
{
"role": "model",
"parts": [
{"functionCall": {"name": "get_weather", "args": {"location": "Paris"}}},
{"functionCall": {"name": "get_weather", "args": {"location": "Tokyo"}}}
]
},
{
"role": "user",
"parts": [
{"functionResponse": {"name": "get_weather", "response": {"content": "{\"temp_c\":18}"}}},
{"functionResponse": {"name": "get_weather", "response": {"content": "{\"temp_c\":27}"}}}
]
}
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"model": "gemini-2.5-pro",
"messages": [
{"role": "system", "content": [{"type": "image_url", "image_url": {"url": "https://x"}}]},
{"role": "user", "content": "Hi"}
]
}
+1
View File
@@ -0,0 +1 @@
{"errContains": "not supported for gemini models", "notSupported": false}
+7
View File
@@ -0,0 +1,7 @@
{
"model": "gemini-2.5-pro",
"messages": [
{"role": "system", "content": [{"type": "text", "text": "Line one."}, {"type": "text", "text": "Line two."}]},
{"role": "user", "content": "Hi"}
]
}
+6
View File
@@ -0,0 +1,6 @@
{
"systemInstruction": {"parts": [{"text": "Line one.\nLine two."}]},
"contents": [
{"role": "user", "parts": [{"text": "Hi"}]}
]
}
+11
View File
@@ -0,0 +1,11 @@
{
"model": "gemini-2.5-pro",
"messages": [{"role": "user", "content": "hi"}],
"tools": [
{
"type": "function",
"function": {"name": "noop", "description": "does nothing", "parameters": {"type": "object", "properties": {}}}
}
],
"tool_choice": "none"
}
+15
View File
@@ -0,0 +1,15 @@
{
"contents": [
{"role": "user", "parts": [{"text": "hi"}]}
],
"tools": [
{
"functionDeclarations": [
{"name": "noop", "description": "does nothing", "parameters": {"type": "object", "properties": {}}}
]
}
],
"toolConfig": {
"functionCallingConfig": {"mode": "NONE"}
}
}
+22
View File
@@ -0,0 +1,22 @@
{
"model": "gemini-2.5-pro",
"messages": [
{"role": "system", "content": "You are a helpful weather bot."},
{"role": "user", "content": "What's the weather in Paris?"}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"]
}
}
}
],
"tool_choice": {"type": "function", "function": {"name": "get_weather"}}
}
+27
View File
@@ -0,0 +1,27 @@
{
"systemInstruction": {"parts": [{"text": "You are a helpful weather bot."}]},
"contents": [
{"role": "user", "parts": [{"text": "What's the weather in Paris?"}]}
],
"tools": [
{
"functionDeclarations": [
{
"name": "get_weather",
"description": "Get current weather for a location",
"parameters": {
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"]
}
}
]
}
],
"toolConfig": {
"functionCallingConfig": {
"mode": "ANY",
"allowedFunctionNames": ["get_weather"]
}
}
}
+5
View File
@@ -0,0 +1,5 @@
{
"model": "gemini-2.5-pro",
"messages": [{"role": "user", "content": "hi"}],
"logit_bias": {"1234": 10}
}
@@ -0,0 +1 @@
{"errContains": "logit_bias is not supported for gemini models", "notSupported": false}
+5
View File
@@ -0,0 +1,5 @@
{
"model": "gemini-2.5-pro",
"messages": [{"role": "user", "content": "hi"}],
"n": 2
}
+1
View File
@@ -0,0 +1 @@
{"errContains": "n is not supported for gemini models", "notSupported": false}
+4
View File
@@ -0,0 +1,4 @@
{
"model": "text-embedding-004",
"input": ["hello", "world!!"]
}
+6
View File
@@ -0,0 +1,6 @@
{
"embeddings": [
{"values": [0.1, 0.2]},
{"values": [0.3, 0.4]}
]
}
+9
View File
@@ -0,0 +1,9 @@
{
"object": "list",
"data": [
{"object": "embedding", "index": 0, "embedding": [0.1, 0.2]},
{"object": "embedding", "index": 1, "embedding": [0.3, 0.4]}
],
"model": "gw-embed-model",
"usage": {"prompt_tokens": 3, "total_tokens": 3}
}
+6
View File
@@ -0,0 +1,6 @@
{
"requests": [
{"model": "models/text-embedding-004", "content": {"parts": [{"text": "hello"}]}},
{"model": "models/text-embedding-004", "content": {"parts": [{"text": "world!!"}]}}
]
}
+4
View File
@@ -0,0 +1,4 @@
{
"model": "text-embedding-004",
"input": "hello world"
}
+3
View File
@@ -0,0 +1,3 @@
{
"embedding": {"values": [0.1, 0.2, 0.3]}
}
+8
View File
@@ -0,0 +1,8 @@
{
"object": "list",
"data": [
{"object": "embedding", "index": 0, "embedding": [0.1, 0.2, 0.3]}
],
"model": "gw-embed-model",
"usage": {"prompt_tokens": 3, "total_tokens": 3}
}
+3
View File
@@ -0,0 +1,3 @@
{
"content": {"parts": [{"text": "hello world"}]}
}
+18
View File
@@ -0,0 +1,18 @@
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{"functionCall": {"id": "fc_1", "name": "get_weather", "args": {"location": "Paris"}}}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 12,
"candidatesTokenCount": 6
},
"responseId": "resp_FUNC1"
}
+24
View File
@@ -0,0 +1,24 @@
{
"id": "chatcmpl-resp_FUNC1",
"object": "chat.completion",
"created": 1734000000,
"model": "gw-gemini-model",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": null,
"tool_calls": [
{
"id": "fc_1",
"type": "function",
"function": {"name": "get_weather", "arguments": "{\"location\":\"Paris\"}"}
}
]
},
"finish_reason": "tool_calls"
}
],
"usage": {"prompt_tokens": 12, "completion_tokens": 6, "total_tokens": 18}
}
+13
View File
@@ -0,0 +1,13 @@
{
"candidates": [
{
"content": {
"role": "model",
"parts": [{"text": "This response got cut off because it"}]
},
"finishReason": "MAX_TOKENS"
}
],
"usageMetadata": {"promptTokenCount": 5, "candidatesTokenCount": 50},
"responseId": "resp_MAXTOK"
}
+14
View File
@@ -0,0 +1,14 @@
{
"id": "chatcmpl-resp_MAXTOK",
"object": "chat.completion",
"created": 1734000000,
"model": "gw-gemini-model",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "This response got cut off because it"},
"finish_reason": "length"
}
],
"usage": {"prompt_tokens": 5, "completion_tokens": 50, "total_tokens": 55}
}
+10
View File
@@ -0,0 +1,10 @@
{
"candidates": [
{
"content": {"role": "model", "parts": []},
"finishReason": "SAFETY"
}
],
"usageMetadata": {"promptTokenCount": 4, "candidatesTokenCount": 0},
"responseId": "resp_SAFETY1"
}
+14
View File
@@ -0,0 +1,14 @@
{
"id": "chatcmpl-resp_SAFETY1",
"object": "chat.completion",
"created": 1734000000,
"model": "gw-gemini-model",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": null},
"finish_reason": "content_filter"
}
],
"usage": {"prompt_tokens": 4, "completion_tokens": 0, "total_tokens": 4}
}
+18
View File
@@ -0,0 +1,18 @@
{
"candidates": [
{
"content": {
"role": "model",
"parts": [{"text": "Hello! How can I help you today?"}]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 8,
"candidatesTokenCount": 9,
"totalTokenCount": 17
},
"modelVersion": "gemini-2.5-pro-001",
"responseId": "resp_ABC123"
}
+14
View File
@@ -0,0 +1,14 @@
{
"id": "chatcmpl-resp_ABC123",
"object": "chat.completion",
"created": 1734000000,
"model": "gw-gemini-model",
"choices": [
{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help you today?"},
"finish_reason": "stop"
}
],
"usage": {"prompt_tokens": 8, "completion_tokens": 9, "total_tokens": 17}
}
+6
View File
@@ -0,0 +1,6 @@
data: {"candidates":[{"content":{"role":"model","parts":[{"text":"Hello"}]}}],"responseId":"resp_STREAM1"}
data: {"candidates":[{"content":{"role":"model","parts":[{"text":", world!"}]}}]}
data: {"candidates":[{"content":{"role":"model","parts":[]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":5,"candidatesTokenCount":3}}
+6
View File
@@ -0,0 +1,6 @@
data: {"candidates":[{"content":{"role":"model","parts":[{"text":"Let me check that."}]}}],"responseId":"resp_STREAM2"}
data: {"candidates":[{"content":{"role":"model","parts":[{"functionCall":{"name":"get_weather","args":{"location":"Berlin"}}}]}}]}
data: {"candidates":[{"content":{"role":"model","parts":[]},"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":10,"candidatesTokenCount":4}}
+1
View File
@@ -0,0 +1 @@
{"prompt": 10, "completion": 4}
+6
View File
@@ -0,0 +1,6 @@
[
{"id":"chatcmpl-resp_STREAM2","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]},
{"id":"chatcmpl-resp_STREAM2","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{"content":"Let me check that."},"finish_reason":null}]},
{"id":"chatcmpl-resp_STREAM2","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_0","type":"function","function":{"name":"get_weather","arguments":"{\"location\":\"Berlin\"}"}}]},"finish_reason":null}]},
{"id":"chatcmpl-resp_STREAM2","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]}
]
+1
View File
@@ -0,0 +1 @@
{"prompt": 5, "completion": 3}
+6
View File
@@ -0,0 +1,6 @@
[
{"id":"chatcmpl-resp_STREAM1","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]},
{"id":"chatcmpl-resp_STREAM1","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]},
{"id":"chatcmpl-resp_STREAM1","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{"content":", world!"},"finish_reason":null}]},
{"id":"chatcmpl-resp_STREAM1","object":"chat.completion.chunk","created":1734000000,"model":"gw-gemini-model","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
]