Compare commits

..
Author SHA1 Message Date
9qeklajc b6cca3d3a0 upstream drops id field which breaks opencode flow 2026-04-13 23:11:07 +02:00
9qeklajcandGitHub 86ebc84f4c Merge pull request #453 from Routstr/remove-hardcoded-fee
remove hardcoded deduction (legacy code)
2026-04-13 22:47:23 +02:00
+9
View File
@@ -5,6 +5,7 @@ import hashlib
import json
import re
import traceback
import uuid
from collections.abc import AsyncGenerator
from typing import Mapping
@@ -521,9 +522,13 @@ class BaseUpstreamProvider:
if isinstance(obj, dict):
if obj.get("model"):
last_model_seen = str(obj.get("model"))
if requested_model:
obj["model"] = requested_model
if "id" not in obj or not isinstance(obj["id"], str):
obj["id"] = f"chatcmpl-{uuid.uuid4()}"
if isinstance(obj.get("usage"), dict):
# Hold this chunk back to merge cost later
usage_chunk_data = obj
@@ -663,6 +668,8 @@ class BaseUpstreamProvider:
if requested_model:
response_json["model"] = requested_model
if "id" not in response_json or not isinstance(response_json["id"], str):
response_json["id"] = f"chatcmpl-{uuid.uuid4()}"
cost_data = await adjust_payment_for_tokens(
key, response_json, session, deducted_max_cost
@@ -992,6 +999,8 @@ class BaseUpstreamProvider:
if requested_model:
response_json["model"] = requested_model
if "id" not in response_json or not isinstance(response_json["id"], str):
response_json["id"] = f"chatcmpl-{uuid.uuid4()}"
cost_data = await adjust_payment_for_tokens(
key, response_json, session, deducted_max_cost