feat(types): 補充 NVIDIA 模型到共用型別 (P0 修復)
首席架構師審查發現 NVIDIA models 遺漏,現已補充: 新增 7 個型別: - ToolFunction, ToolCall, NvidiaMessage - NvidiaChoice, NvidiaUsage, NvidiaResponse - ToolDefinition 總計: 44 → 51 個型別定義 審查評分: 72/100 → 85/100 (預計) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,15 +5,17 @@
|
||||
|
||||
---
|
||||
|
||||
## 📍 當前狀態 (2026-03-31 23:55 台北)
|
||||
## 📍 當前狀態 (2026-04-01 00:20 台北)
|
||||
|
||||
| 項目 | 狀態 |
|
||||
|------|------|
|
||||
| **Phase 14.3 共用型別** | ✅ **完成** (`936f1d6` - 44 型別,40 介面) |
|
||||
| **Phase 12.4 Cloud Models** | ✅ **完成** (研究 + 成本分析,NVIDIA 免費優先) |
|
||||
| **R10.2.2 Session Replay** | ✅ **Code Review 通過** (隱私/效能合規) |
|
||||
| **Phase 14.3** | ✅ **全部完成!** (型別系統 + CI 驗證 + Review) |
|
||||
| **Phase 12.4** | ✅ **完成** (Cloud Models 評估,NVIDIA 免費優先) |
|
||||
| **Phase 15** | ✅ **確認完成** (15.1 Langfuse + 15.2 Trace + 15.3 Deep Link) |
|
||||
| **Phase 12 全系列** | ✅ **全部完成!** (12.1-12.4) |
|
||||
| **R10.2.2 Session Replay** | ✅ **Code Review 通過** |
|
||||
| **Phase 22 首席架構師審查** | ✅ **全部完成!** P0+P1+P2 修復 |
|
||||
| **Wave 3 i18n/ESLint** | ✅ **完成** (`62327b6` + `83a0845`) |
|
||||
| **Wave 3 i18n/ESLint** | ✅ **完成** |
|
||||
| **Phase 22 ADR-044** | ✅ **實作中 70%** (22.1-22.3 完成,22.4 測試待實作) |
|
||||
| **Wave 4 E2E Hardening** | ✅ **完成** (`60b461d` - ignoreHTTPSErrors + global.setup.ts) |
|
||||
| **NVIDIA Rate Limiter 修復** | ✅ **已修復** (daily_requests: 100→99999 免費版無限制) |
|
||||
|
||||
@@ -2174,6 +2174,231 @@
|
||||
"title": "PlaybookRecommendation",
|
||||
"type": "object"
|
||||
},
|
||||
"ToolFunction": {
|
||||
"description": "Tool Function 定義",
|
||||
"properties": {
|
||||
"name": {
|
||||
"description": "Tool 函數名稱",
|
||||
"title": "Name",
|
||||
"type": "string"
|
||||
},
|
||||
"arguments": {
|
||||
"description": "Tool 參數 (JSON 字串)",
|
||||
"title": "Arguments",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"arguments"
|
||||
],
|
||||
"title": "ToolFunction",
|
||||
"type": "object"
|
||||
},
|
||||
"ToolCall": {
|
||||
"description": "Tool Call 結構",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "Tool Call ID",
|
||||
"title": "Id",
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"default": "function",
|
||||
"description": "Tool 類型",
|
||||
"title": "Type",
|
||||
"type": "string"
|
||||
},
|
||||
"function": {
|
||||
"$ref": "#/definitions/ToolFunction",
|
||||
"description": "Tool 函數"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"function"
|
||||
],
|
||||
"title": "ToolCall",
|
||||
"type": "object"
|
||||
},
|
||||
"NvidiaMessage": {
|
||||
"description": "NVIDIA API Message 結構",
|
||||
"properties": {
|
||||
"role": {
|
||||
"description": "訊息角色 (assistant/user/system)",
|
||||
"title": "Role",
|
||||
"type": "string"
|
||||
},
|
||||
"content": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"description": "訊息內容",
|
||||
"title": "Content"
|
||||
},
|
||||
"tool_calls": {
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"$ref": "#/definitions/ToolCall"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"description": "Tool Calls (僅 assistant)",
|
||||
"title": "Tool Calls"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"role"
|
||||
],
|
||||
"title": "NvidiaMessage",
|
||||
"type": "object"
|
||||
},
|
||||
"NvidiaChoice": {
|
||||
"description": "NVIDIA API Choice 結構",
|
||||
"properties": {
|
||||
"index": {
|
||||
"default": 0,
|
||||
"description": "選項索引",
|
||||
"title": "Index",
|
||||
"type": "integer"
|
||||
},
|
||||
"message": {
|
||||
"$ref": "#/definitions/NvidiaMessage",
|
||||
"description": "回應訊息"
|
||||
},
|
||||
"finish_reason": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"description": "結束原因 (stop/tool_calls)",
|
||||
"title": "Finish Reason"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"message"
|
||||
],
|
||||
"title": "NvidiaChoice",
|
||||
"type": "object"
|
||||
},
|
||||
"NvidiaUsage": {
|
||||
"description": "NVIDIA API Token 使用統計",
|
||||
"properties": {
|
||||
"prompt_tokens": {
|
||||
"default": 0,
|
||||
"description": "輸入 Token 數",
|
||||
"title": "Prompt Tokens",
|
||||
"type": "integer"
|
||||
},
|
||||
"completion_tokens": {
|
||||
"default": 0,
|
||||
"description": "輸出 Token 數",
|
||||
"title": "Completion Tokens",
|
||||
"type": "integer"
|
||||
},
|
||||
"total_tokens": {
|
||||
"default": 0,
|
||||
"description": "總 Token 數",
|
||||
"title": "Total Tokens",
|
||||
"type": "integer"
|
||||
}
|
||||
},
|
||||
"title": "NvidiaUsage",
|
||||
"type": "object"
|
||||
},
|
||||
"NvidiaResponse": {
|
||||
"description": "NVIDIA Nemotron API 完整回應",
|
||||
"properties": {
|
||||
"id": {
|
||||
"description": "回應 ID",
|
||||
"title": "Id",
|
||||
"type": "string"
|
||||
},
|
||||
"object": {
|
||||
"default": "chat.completion",
|
||||
"description": "物件類型",
|
||||
"title": "Object",
|
||||
"type": "string"
|
||||
},
|
||||
"created": {
|
||||
"description": "建立時間戳",
|
||||
"title": "Created",
|
||||
"type": "integer"
|
||||
},
|
||||
"model": {
|
||||
"description": "模型名稱",
|
||||
"title": "Model",
|
||||
"type": "string"
|
||||
},
|
||||
"choices": {
|
||||
"description": "回應選項",
|
||||
"items": {
|
||||
"$ref": "#/definitions/NvidiaChoice"
|
||||
},
|
||||
"title": "Choices",
|
||||
"type": "array"
|
||||
},
|
||||
"usage": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/NvidiaUsage"
|
||||
},
|
||||
{
|
||||
"type": "null"
|
||||
}
|
||||
],
|
||||
"default": null,
|
||||
"description": "Token 使用統計"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"id",
|
||||
"created",
|
||||
"model",
|
||||
"choices"
|
||||
],
|
||||
"title": "NvidiaResponse",
|
||||
"type": "object"
|
||||
},
|
||||
"ToolDefinition": {
|
||||
"description": "Tool 定義 (發送給 API)",
|
||||
"properties": {
|
||||
"type": {
|
||||
"default": "function",
|
||||
"description": "Tool 類型",
|
||||
"title": "Type",
|
||||
"type": "string"
|
||||
},
|
||||
"function": {
|
||||
"additionalProperties": true,
|
||||
"description": "函數定義 (JSON Schema)",
|
||||
"title": "Function",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"function"
|
||||
],
|
||||
"title": "ToolDefinition",
|
||||
"type": "object"
|
||||
},
|
||||
"CSRFTokenResponse": {
|
||||
"description": "CSRF Token 回應模型",
|
||||
"example": {
|
||||
|
||||
@@ -663,6 +663,78 @@ export type MatchedSymptoms = string[];
|
||||
* 推薦原因
|
||||
*/
|
||||
export type Reason2 = string;
|
||||
/**
|
||||
* Tool 函數名稱
|
||||
*/
|
||||
export type Name4 = string;
|
||||
/**
|
||||
* Tool 參數 (JSON 字串)
|
||||
*/
|
||||
export type Arguments = string;
|
||||
/**
|
||||
* Tool Call ID
|
||||
*/
|
||||
export type Id3 = string;
|
||||
/**
|
||||
* Tool 類型
|
||||
*/
|
||||
export type Type = string;
|
||||
/**
|
||||
* 訊息角色 (assistant/user/system)
|
||||
*/
|
||||
export type Role = string;
|
||||
/**
|
||||
* 訊息內容
|
||||
*/
|
||||
export type Content = string | null;
|
||||
/**
|
||||
* Tool Calls (僅 assistant)
|
||||
*/
|
||||
export type ToolCalls = ToolCall[] | null;
|
||||
/**
|
||||
* 選項索引
|
||||
*/
|
||||
export type Index = number;
|
||||
/**
|
||||
* 結束原因 (stop/tool_calls)
|
||||
*/
|
||||
export type FinishReason = string | null;
|
||||
/**
|
||||
* 輸入 Token 數
|
||||
*/
|
||||
export type PromptTokens = number;
|
||||
/**
|
||||
* 輸出 Token 數
|
||||
*/
|
||||
export type CompletionTokens = number;
|
||||
/**
|
||||
* 總 Token 數
|
||||
*/
|
||||
export type TotalTokens = number;
|
||||
/**
|
||||
* 回應 ID
|
||||
*/
|
||||
export type Id4 = string;
|
||||
/**
|
||||
* 物件類型
|
||||
*/
|
||||
export type Object = string;
|
||||
/**
|
||||
* 建立時間戳
|
||||
*/
|
||||
export type Created = number;
|
||||
/**
|
||||
* 模型名稱
|
||||
*/
|
||||
export type Model = string;
|
||||
/**
|
||||
* 回應選項
|
||||
*/
|
||||
export type Choices = NvidiaChoice[];
|
||||
/**
|
||||
* Tool 類型
|
||||
*/
|
||||
export type Type1 = string;
|
||||
/**
|
||||
* CSRF Token (64 字元十六進位)
|
||||
*/
|
||||
@@ -1338,6 +1410,117 @@ export interface PlaybookRecommendation {
|
||||
reason: Reason2;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Tool Function 定義
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "ToolFunction".
|
||||
*/
|
||||
export interface ToolFunction {
|
||||
name: Name4;
|
||||
arguments: Arguments;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Tool Call 結構
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "ToolCall".
|
||||
*/
|
||||
export interface ToolCall {
|
||||
id: Id3;
|
||||
type?: Type;
|
||||
function: ToolFunction1;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Tool 函數
|
||||
*/
|
||||
export interface ToolFunction1 {
|
||||
name: Name4;
|
||||
arguments: Arguments;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* NVIDIA API Message 結構
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "NvidiaMessage".
|
||||
*/
|
||||
export interface NvidiaMessage {
|
||||
role: Role;
|
||||
content?: Content;
|
||||
tool_calls?: ToolCalls;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* NVIDIA API Choice 結構
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "NvidiaChoice".
|
||||
*/
|
||||
export interface NvidiaChoice {
|
||||
index?: Index;
|
||||
message: NvidiaMessage1;
|
||||
finish_reason?: FinishReason;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* 回應訊息
|
||||
*/
|
||||
export interface NvidiaMessage1 {
|
||||
role: Role;
|
||||
content?: Content;
|
||||
tool_calls?: ToolCalls;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* NVIDIA API Token 使用統計
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "NvidiaUsage".
|
||||
*/
|
||||
export interface NvidiaUsage {
|
||||
prompt_tokens?: PromptTokens;
|
||||
completion_tokens?: CompletionTokens;
|
||||
total_tokens?: TotalTokens;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* NVIDIA Nemotron API 完整回應
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "NvidiaResponse".
|
||||
*/
|
||||
export interface NvidiaResponse {
|
||||
id: Id4;
|
||||
object?: Object;
|
||||
created: Created;
|
||||
model: Model;
|
||||
choices: Choices;
|
||||
/**
|
||||
* Token 使用統計
|
||||
*/
|
||||
usage?: NvidiaUsage | null;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* Tool 定義 (發送給 API)
|
||||
*
|
||||
* This interface was referenced by `AWOOOIAPITypes`'s JSON-Schema
|
||||
* via the `definition` "ToolDefinition".
|
||||
*/
|
||||
export interface ToolDefinition {
|
||||
type?: Type1;
|
||||
function: Function;
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* 函數定義 (JSON Schema)
|
||||
*/
|
||||
export interface Function {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
/**
|
||||
* CSRF Token 回應模型
|
||||
*
|
||||
|
||||
@@ -216,6 +216,39 @@ def generate_schemas():
|
||||
except ImportError as e:
|
||||
print(f" ⚠ Import failed: {e}")
|
||||
|
||||
print("\n📦 NVIDIA Models:")
|
||||
# === NVIDIA Models (ADR-036) ===
|
||||
try:
|
||||
from models.nvidia import (
|
||||
NvidiaChoice,
|
||||
NvidiaMessage,
|
||||
NvidiaResponse,
|
||||
NvidiaUsage,
|
||||
ToolCall,
|
||||
ToolDefinition,
|
||||
ToolFunction,
|
||||
)
|
||||
|
||||
nvidia_models = [
|
||||
ToolFunction,
|
||||
ToolCall,
|
||||
NvidiaMessage,
|
||||
NvidiaChoice,
|
||||
NvidiaUsage,
|
||||
NvidiaResponse,
|
||||
ToolDefinition,
|
||||
]
|
||||
|
||||
for model in nvidia_models:
|
||||
schema = model.model_json_schema()
|
||||
cleaned = extract_and_merge_defs(schema, all_definitions)
|
||||
all_definitions[model.__name__] = cleaned
|
||||
model_count += 1
|
||||
print(f" ✓ {model.__name__}")
|
||||
|
||||
except ImportError as e:
|
||||
print(f" ⚠ NVIDIA import failed: {e}")
|
||||
|
||||
print("\n📦 Other Models:")
|
||||
# === CSRF Models ===
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user