From 83bc348fde3838b669b096636771ce21ccaa8464 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 11 Aug 2025 15:22:57 +0000 Subject: [PATCH 1/6] Add reasoning effort tracking to logs and UI Co-authored-by: contact --- apps/api/src/routes/logs.ts | 1 + apps/gateway/src/chat/chat.ts | 12 ++++++++ apps/ui/src/components/dashboard/log-card.tsx | 28 +++++++++++++++++++ packages/db/src/schema.ts | 2 ++ 4 files changed, 43 insertions(+) diff --git a/apps/api/src/routes/logs.ts b/apps/api/src/routes/logs.ts index f4150d6f37..ce46ce717b 100644 --- a/apps/api/src/routes/logs.ts +++ b/apps/api/src/routes/logs.ts @@ -55,6 +55,7 @@ const logSchema = z.object({ topP: z.number().nullable(), frequencyPenalty: z.number().nullable(), presencePenalty: z.number().nullable(), + reasoningEffort: z.string().nullable(), tools: tools.nullable(), toolChoice: toolChoice.nullable(), toolResults: toolResults.nullable(), diff --git a/apps/gateway/src/chat/chat.ts b/apps/gateway/src/chat/chat.ts index 81f75d55d3..cddf4d0bd3 100644 --- a/apps/gateway/src/chat/chat.ts +++ b/apps/gateway/src/chat/chat.ts @@ -152,6 +152,8 @@ function createLogEntry( top_p: number | undefined, frequency_penalty: number | undefined, presence_penalty: number | undefined, + // NEW: include reasoning effort for logging + reasoningEffort: "low" | "medium" | "high" | undefined, tools: any[] | undefined, toolChoice: any | undefined, source: string | undefined, @@ -173,6 +175,8 @@ function createLogEntry( topP: top_p || null, frequencyPenalty: frequency_penalty || null, presencePenalty: presence_penalty || null, + // NEW: store normalized reasoning effort + reasoningEffort: reasoningEffort || null, tools: tools || null, toolChoice: toolChoice || null, mode: project.mode, @@ -2067,6 +2071,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -2147,6 +2152,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -2322,6 +2328,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -2437,6 +2444,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -3137,6 +3145,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -3261,6 +3270,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -3330,6 +3340,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, @@ -3469,6 +3480,7 @@ chat.openapi(completions, async (c) => { top_p, frequency_penalty, presence_penalty, + reasoning_effort, tools, tool_choice, source, diff --git a/apps/ui/src/components/dashboard/log-card.tsx b/apps/ui/src/components/dashboard/log-card.tsx index 030afdfe53..8a7e5a0e87 100644 --- a/apps/ui/src/components/dashboard/log-card.tsx +++ b/apps/ui/src/components/dashboard/log-card.tsx @@ -93,6 +93,18 @@ export function LogCard({ log }: { log: Partial }) { {log.totalTokens} tokens + {log.promptTokens && ( +
+ + Prompt: {log.promptTokens} +
+ )} + {log.reasoningTokens && ( +
+ + Reasoning: {log.reasoningTokens} +
+ )}
{formatDuration(log.duration ?? 0)} @@ -348,6 +360,22 @@ export function LogCard({ log }: { log: Partial }) { {log.frequencyPenalty}
+
+ + + + Reasoning Effort + + + +

+ Requested chain-of-thought effort for reasoning-capable + models +

+
+
+ {log.reasoningEffort || "-"} +
diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index 9895ba85bd..7db436d2b9 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -281,6 +281,8 @@ export const log = pgTable("log", { topP: real(), frequencyPenalty: real(), presencePenalty: real(), + // Add reasoning effort selection for reasoning-capable models + reasoningEffort: text(), hasError: boolean().default(false), errorDetails: json().$type>(), cost: real(), From 8c09ea7c0ecdb2a085039e02f9ad7b812648d687 Mon Sep 17 00:00:00 2001 From: "Luca Steeb (bot)" Date: Mon, 11 Aug 2025 15:24:02 +0000 Subject: [PATCH 2/6] chore(autofix): apply diff --- apps/ui/src/lib/api/v1.d.ts | 1 + .../migrations/1754925816_long_wildside.sql | 1 + .../migrations/meta/1754925816_snapshot.json | 1753 +++++++++++++++++ packages/db/migrations/meta/_journal.json | 7 + 4 files changed, 1762 insertions(+) create mode 100644 packages/db/migrations/1754925816_long_wildside.sql create mode 100644 packages/db/migrations/meta/1754925816_snapshot.json diff --git a/apps/ui/src/lib/api/v1.d.ts b/apps/ui/src/lib/api/v1.d.ts index 37e9bdf4e8..ac654fb422 100644 --- a/apps/ui/src/lib/api/v1.d.ts +++ b/apps/ui/src/lib/api/v1.d.ts @@ -525,6 +525,7 @@ export interface paths { topP: number | null; frequencyPenalty: number | null; presencePenalty: number | null; + reasoningEffort: string | null; tools: | { /** @enum {string} */ diff --git a/packages/db/migrations/1754925816_long_wildside.sql b/packages/db/migrations/1754925816_long_wildside.sql new file mode 100644 index 0000000000..a16c047dee --- /dev/null +++ b/packages/db/migrations/1754925816_long_wildside.sql @@ -0,0 +1 @@ +ALTER TABLE "log" ADD COLUMN "reasoning_effort" text; \ No newline at end of file diff --git a/packages/db/migrations/meta/1754925816_snapshot.json b/packages/db/migrations/meta/1754925816_snapshot.json new file mode 100644 index 0000000000..6c618d49fc --- /dev/null +++ b/packages/db/migrations/meta/1754925816_snapshot.json @@ -0,0 +1,1753 @@ +{ + "id": "87b6f666-76e9-4eff-8800-8e44351e241a", + "prevId": "2df460fa-291f-48a2-bf14-41b15817ad58", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.api_key": { + "name": "api_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + }, + "usage_limit": { + "name": "usage_limit", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "usage": { + "name": "usage", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "api_key_project_id_project_id_fk": { + "name": "api_key_project_id_project_id_fk", + "tableFrom": "api_key", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "api_key_token_unique": { + "name": "api_key_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.chat": { + "name": "chat", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "model": { + "name": "model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + } + }, + "indexes": {}, + "foreignKeys": { + "chat_user_id_user_id_fk": { + "name": "chat_user_id_user_id_fk", + "tableFrom": "chat", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.installation": { + "name": "installation", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "uuid": { + "name": "uuid", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "installation_uuid_unique": { + "name": "installation_uuid_unique", + "nullsNotDistinct": false, + "columns": [ + "uuid" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.lock": { + "name": "lock", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "lock_key_unique": { + "name": "lock_key_unique", + "nullsNotDistinct": false, + "columns": [ + "key" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.log": { + "name": "log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "request_id": { + "name": "request_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "project_id": { + "name": "project_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "api_key_id": { + "name": "api_key_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "duration": { + "name": "duration", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "requested_model": { + "name": "requested_model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "requested_provider": { + "name": "requested_provider", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "used_model": { + "name": "used_model", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_provider": { + "name": "used_provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "response_size": { + "name": "response_size", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reasoning_content": { + "name": "reasoning_content", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "tools": { + "name": "tools", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "tool_choice": { + "name": "tool_choice", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "tool_results": { + "name": "tool_results", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "finish_reason": { + "name": "finish_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "unified_finish_reason": { + "name": "unified_finish_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prompt_tokens": { + "name": "prompt_tokens", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "completion_tokens": { + "name": "completion_tokens", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "total_tokens": { + "name": "total_tokens", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "reasoning_tokens": { + "name": "reasoning_tokens", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "cached_tokens": { + "name": "cached_tokens", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "messages": { + "name": "messages", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "temperature": { + "name": "temperature", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "max_tokens": { + "name": "max_tokens", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "top_p": { + "name": "top_p", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "frequency_penalty": { + "name": "frequency_penalty", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "presence_penalty": { + "name": "presence_penalty", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "reasoning_effort": { + "name": "reasoning_effort", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "has_error": { + "name": "has_error", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "error_details": { + "name": "error_details", + "type": "json", + "primaryKey": false, + "notNull": false + }, + "cost": { + "name": "cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "input_cost": { + "name": "input_cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "output_cost": { + "name": "output_cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "cached_input_cost": { + "name": "cached_input_cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "request_cost": { + "name": "request_cost", + "type": "real", + "primaryKey": false, + "notNull": false + }, + "estimated_cost": { + "name": "estimated_cost", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "canceled": { + "name": "canceled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "streamed": { + "name": "streamed", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "cached": { + "name": "cached", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "used_mode": { + "name": "used_mode", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "custom_headers": { + "name": "custom_headers", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "log_organization_id_organization_id_fk": { + "name": "log_organization_id_organization_id_fk", + "tableFrom": "log", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "log_project_id_project_id_fk": { + "name": "log_project_id_project_id_fk", + "tableFrom": "log", + "tableTo": "project", + "columnsFrom": [ + "project_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "log_api_key_id_api_key_id_fk": { + "name": "log_api_key_id_api_key_id_fk", + "tableFrom": "log", + "tableTo": "api_key", + "columnsFrom": [ + "api_key_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.message": { + "name": "message", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "chat_id": { + "name": "chat_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sequence": { + "name": "sequence", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "message_chat_id_chat_id_fk": { + "name": "message_chat_id_chat_id_fk", + "tableFrom": "message", + "tableTo": "chat", + "columnsFrom": [ + "chat_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization": { + "name": "organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stripe_customer_id": { + "name": "stripe_customer_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_subscription_id": { + "name": "stripe_subscription_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "credits": { + "name": "credits", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0'" + }, + "auto_top_up_enabled": { + "name": "auto_top_up_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "auto_top_up_threshold": { + "name": "auto_top_up_threshold", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'10'" + }, + "auto_top_up_amount": { + "name": "auto_top_up_amount", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'10'" + }, + "plan": { + "name": "plan", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'free'" + }, + "plan_expires_at": { + "name": "plan_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "subscription_cancelled": { + "name": "subscription_cancelled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "trial_start_date": { + "name": "trial_start_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "trial_end_date": { + "name": "trial_end_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "is_trial_active": { + "name": "is_trial_active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "retention_level": { + "name": "retention_level", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'retain'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "organization_stripeCustomerId_unique": { + "name": "organization_stripeCustomerId_unique", + "nullsNotDistinct": false, + "columns": [ + "stripe_customer_id" + ] + }, + "organization_stripeSubscriptionId_unique": { + "name": "organization_stripeSubscriptionId_unique", + "nullsNotDistinct": false, + "columns": [ + "stripe_subscription_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.organization_action": { + "name": "organization_action", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "organization_action_organization_id_organization_id_fk": { + "name": "organization_action_organization_id_organization_id_fk", + "tableFrom": "organization_action", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.passkey": { + "name": "passkey", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "credential_id": { + "name": "credential_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "counter": { + "name": "counter", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "device_type": { + "name": "device_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "backed_up": { + "name": "backed_up", + "type": "boolean", + "primaryKey": false, + "notNull": false + }, + "transports": { + "name": "transports", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "passkey_user_id_user_id_fk": { + "name": "passkey_user_id_user_id_fk", + "tableFrom": "passkey", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.payment_method": { + "name": "payment_method", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "stripe_payment_method_id": { + "name": "stripe_payment_method_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "is_default": { + "name": "is_default", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": { + "payment_method_organization_id_organization_id_fk": { + "name": "payment_method_organization_id_organization_id_fk", + "tableFrom": "payment_method", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.project": { + "name": "project", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "caching_enabled": { + "name": "caching_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "cache_duration_seconds": { + "name": "cache_duration_seconds", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 60 + }, + "mode": { + "name": "mode", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'hybrid'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + } + }, + "indexes": {}, + "foreignKeys": { + "project_organization_id_organization_id_fk": { + "name": "project_organization_id_organization_id_fk", + "tableFrom": "project", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.provider_key": { + "name": "provider_key", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "base_url": { + "name": "base_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'active'" + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "provider_key_organization_id_organization_id_fk": { + "name": "provider_key_organization_id_organization_id_fk", + "tableFrom": "provider_key", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provider_key_organizationId_name_unique": { + "name": "provider_key_organizationId_name_unique", + "nullsNotDistinct": false, + "columns": [ + "organization_id", + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.transaction": { + "name": "transaction", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "amount": { + "name": "amount", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "credit_amount": { + "name": "credit_amount", + "type": "numeric", + "primaryKey": false, + "notNull": false + }, + "currency": { + "name": "currency", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'USD'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'completed'" + }, + "stripe_payment_intent_id": { + "name": "stripe_payment_intent_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "stripe_invoice_id": { + "name": "stripe_invoice_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "transaction_organization_id_organization_id_fk": { + "name": "transaction_organization_id_organization_id_fk", + "tableFrom": "transaction", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "onboarding_completed": { + "name": "onboarding_completed", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user_organization": { + "name": "user_organization", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "organization_id": { + "name": "organization_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "user_organization_user_id_user_id_fk": { + "name": "user_organization_user_id_user_id_fk", + "tableFrom": "user_organization", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_organization_organization_id_organization_id_fk": { + "name": "user_organization_organization_id_organization_id_fk", + "tableFrom": "user_organization", + "tableTo": "organization", + "columnsFrom": [ + "organization_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": {}, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/db/migrations/meta/_journal.json b/packages/db/migrations/meta/_journal.json index 208c384338..b07988335e 100644 --- a/packages/db/migrations/meta/_journal.json +++ b/packages/db/migrations/meta/_journal.json @@ -260,6 +260,13 @@ "when": 1754525073775, "tag": "1754525073_demonic_human_fly", "breakpoints": true + }, + { + "idx": 37, + "version": "7", + "when": 1754925816984, + "tag": "1754925816_long_wildside", + "breakpoints": true } ] } \ No newline at end of file From 65beb442257aae08fee8905dbeac0868615195c6 Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Wed, 13 Aug 2025 01:37:00 +0200 Subject: [PATCH 3/6] Update chat.ts --- apps/gateway/src/chat/chat.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/gateway/src/chat/chat.ts b/apps/gateway/src/chat/chat.ts index cddf4d0bd3..9d24d00f65 100644 --- a/apps/gateway/src/chat/chat.ts +++ b/apps/gateway/src/chat/chat.ts @@ -152,7 +152,6 @@ function createLogEntry( top_p: number | undefined, frequency_penalty: number | undefined, presence_penalty: number | undefined, - // NEW: include reasoning effort for logging reasoningEffort: "low" | "medium" | "high" | undefined, tools: any[] | undefined, toolChoice: any | undefined, @@ -175,7 +174,6 @@ function createLogEntry( topP: top_p || null, frequencyPenalty: frequency_penalty || null, presencePenalty: presence_penalty || null, - // NEW: store normalized reasoning effort reasoningEffort: reasoningEffort || null, tools: tools || null, toolChoice: toolChoice || null, From dea50eec2cfbc4ec2c1bce47144a7ea7d24ec137 Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Wed, 13 Aug 2025 01:38:23 +0200 Subject: [PATCH 4/6] Update schema.ts --- packages/db/src/schema.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/db/src/schema.ts b/packages/db/src/schema.ts index 7db436d2b9..3357e4bac2 100644 --- a/packages/db/src/schema.ts +++ b/packages/db/src/schema.ts @@ -281,7 +281,6 @@ export const log = pgTable("log", { topP: real(), frequencyPenalty: real(), presencePenalty: real(), - // Add reasoning effort selection for reasoning-capable models reasoningEffort: text(), hasError: boolean().default(false), errorDetails: json().$type>(), From b2302a3f28938bba34eee4d8f0a7970c8b4b48b4 Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Wed, 13 Aug 2025 01:52:10 +0200 Subject: [PATCH 5/6] fix(ui): remove unused token displays in log-card Removed prompt and reasoning token displays from the dashboard log-card component as they are no longer relevant. --- apps/ui/src/components/dashboard/log-card.tsx | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/apps/ui/src/components/dashboard/log-card.tsx b/apps/ui/src/components/dashboard/log-card.tsx index 8a7e5a0e87..0041764e4f 100644 --- a/apps/ui/src/components/dashboard/log-card.tsx +++ b/apps/ui/src/components/dashboard/log-card.tsx @@ -93,18 +93,6 @@ export function LogCard({ log }: { log: Partial }) { {log.totalTokens} tokens - {log.promptTokens && ( -
- - Prompt: {log.promptTokens} -
- )} - {log.reasoningTokens && ( -
- - Reasoning: {log.reasoningTokens} -
- )}
{formatDuration(log.duration ?? 0)} From ec084e56dfcf4b3f530cac2f1cadf464c46fe73e Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Wed, 13 Aug 2025 01:55:55 +0200 Subject: [PATCH 6/6] feat(ui): display reasoning tokens in log-card Added a new reasoning token display to the dashboard log-card component. Updated model configurations to support the reasoning capability. --- apps/ui/src/components/dashboard/log-card.tsx | 2 ++ packages/models/src/models/openai.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apps/ui/src/components/dashboard/log-card.tsx b/apps/ui/src/components/dashboard/log-card.tsx index 0041764e4f..1c58cada6c 100644 --- a/apps/ui/src/components/dashboard/log-card.tsx +++ b/apps/ui/src/components/dashboard/log-card.tsx @@ -164,6 +164,8 @@ export function LogCard({ log }: { log: Partial }) {
{log.promptTokens}
Completion Tokens
{log.completionTokens}
+
Reasoning Tokens
+
{log.reasoningTokens}
Total Tokens
{log.totalTokens}
{log.reasoningTokens && ( diff --git a/packages/models/src/models/openai.ts b/packages/models/src/models/openai.ts index 6348d9bc53..ecfa131825 100644 --- a/packages/models/src/models/openai.ts +++ b/packages/models/src/models/openai.ts @@ -293,6 +293,7 @@ export const openaiModels = [ streaming: true, vision: false, tools: true, + reasoning: true, }, ], jsonOutput: true, @@ -315,6 +316,7 @@ export const openaiModels = [ streaming: true, vision: false, tools: true, + reasoning: true, }, ], jsonOutput: true,