fix(api): 修復 34 個 Ruff lint 錯誤

- 自動修復 import 排序、unused imports
- 手動修復 raise from、isinstance union、unused variable
- scripts/ 暫時保留 (非 CI 阻擋)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-03-29 15:27:49 +08:00
parent 5f9a6a7e55
commit d89f0520f9
27 changed files with 2538 additions and 1132 deletions

View File

@@ -11,12 +11,11 @@ Nemotron Tool Calling 精準度測試
日期: 2026-03-28 (台北時間)
"""
import os
import json
import asyncio
import json
import os
import time
from dataclasses import dataclass
from typing import Optional
try:
import httpx
@@ -198,11 +197,11 @@ class TestResult:
test_id: str
description: str
success: bool
tool_called: Optional[str]
params: Optional[dict]
tool_called: str | None
params: dict | None
latency_ms: float
error: Optional[str] = None
raw_response: Optional[str] = None
error: str | None = None
raw_response: str | None = None
async def call_nemotron(prompt: str, model: str = "nvidia/nemotron-mini-4b-instruct") -> dict:
@@ -328,7 +327,7 @@ async def run_single_test(test_case: dict) -> list:
prompt = test_case["prompt"]
# 測試 Nemotron
print(f" Testing Nemotron...", end=" ", flush=True)
print(" Testing Nemotron...", end=" ", flush=True)
resp = await call_nemotron(prompt)
if resp["error"]:
results.append(TestResult(
@@ -341,7 +340,7 @@ async def run_single_test(test_case: dict) -> list:
latency_ms=resp["latency_ms"],
error=resp["error"]
))
print(f"❌ Error")
print("❌ Error")
else:
tool, params, error = parse_nemotron_response(resp["data"])
success = tool == test_case["expected_tool"]
@@ -365,7 +364,7 @@ async def run_single_test(test_case: dict) -> list:
print(f"{status} {tool} ({resp['latency_ms']:.0f}ms)")
# 測試 Ollama
print(f" Testing Ollama...", end=" ", flush=True)
print(" Testing Ollama...", end=" ", flush=True)
resp = await call_ollama(prompt)
if resp["error"]:
results.append(TestResult(
@@ -404,7 +403,7 @@ async def main():
print("🧪 Nemotron vs Ollama Tool Calling 精準度測試")
print("=" * 70)
print()
print(f"Nemotron API: integrate.api.nvidia.com")
print("Nemotron API: integrate.api.nvidia.com")
print(f"Ollama URL: {OLLAMA_BASE_URL}")
print()