Skip to content

Commit 9f5e9af

Browse files
committed
Add PromptRuntime type and update invoke usage
Introduced the PromptRuntime interface in ArenaWindow and updated invoke calls to use type inference for better type safety. Also removed unused import of X from lucide-react in ArenaWindow. Minor formatting adjustments in ArenaHistoryWindow.
1 parent 8057870 commit 9f5e9af

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/components/arena/ArenaHistoryWindow.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export default function ArenaHistoryWindow({ onClose, isStandaloneWindow = false
254254
{(() => {
255255
const outputs = parseOutputs(selectedBattle.outputs);
256256
const modelCount = outputs.length;
257-
257+
258258
// 调试日志:显示 winner_model 的值
259259
if (selectedBattle.winner_model) {
260260
console.log("[Arena History] Winner model:", selectedBattle.winner_model);
@@ -288,14 +288,13 @@ export default function ArenaHistoryWindow({ onClose, isStandaloneWindow = false
288288
{outputs.map((output) => {
289289
const modelKey = output.model_id || output.model || "unknown";
290290
const modelName = output.model_name || output.metadata.model;
291-
const providerName = output.provider_name || output.metadata.provider;
292291
const providerType = output.provider_type || output.metadata.provider;
293292

294293
// 尝试多种方式匹配 winner:model_name, model_id, 或 metadata.model
295-
const isWinner = selectedBattle.winner_model === modelName ||
296-
selectedBattle.winner_model === modelKey ||
297-
selectedBattle.winner_model === output.metadata.model;
298-
294+
const isWinner = selectedBattle.winner_model === modelName ||
295+
selectedBattle.winner_model === modelKey ||
296+
selectedBattle.winner_model === output.metadata.model;
297+
299298
// 调试日志
300299
if (selectedBattle.winner_model) {
301300
console.log(`[Arena History] Checking ${modelName}: isWinner=${isWinner}`, {
@@ -305,7 +304,7 @@ export default function ArenaHistoryWindow({ onClose, isStandaloneWindow = false
305304
metadata_model: output.metadata.model
306305
});
307306
}
308-
307+
309308
const votes = selectedBattle.votes ? JSON.parse(selectedBattle.votes) : {};
310309
const hasVoted = votes[modelName] === 1;
311310

src/components/arena/ArenaWindow.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useState, useEffect } from "react";
22
import { useTranslation } from "react-i18next";
33
import { invoke } from "@tauri-apps/api/tauri";
4-
import { Play, Loader2, Check, Trophy, X } from "lucide-react";
4+
import { Play, Loader2, Check, Trophy } from "lucide-react";
55
import PromptPreview from "./PromptPreview";
66
import VoteCard from "./VoteCard";
77
import { appWindow } from "@tauri-apps/api/window";
@@ -53,6 +53,15 @@ interface ArenaSettings {
5353
card_density: string;
5454
}
5555

56+
interface PromptRuntime {
57+
config: {
58+
model: string;
59+
provider: string;
60+
[key: string]: any;
61+
};
62+
[key: string]: any;
63+
}
64+
5665
export default function ArenaWindow({ onClose, isStandaloneWindow = false }: ArenaWindowProps) {
5766
const { t } = useTranslation();
5867

@@ -227,7 +236,7 @@ export default function ArenaWindow({ onClose, isStandaloneWindow = false }: Are
227236
console.log(`[Arena] Final API key length: ${apiKey.length}`);
228237

229238
// Load runtime and replace model
230-
const runtime = await invoke("load_prompt_runtime", {
239+
const runtime = await invoke<PromptRuntime>("load_prompt_runtime", {
231240
filePath: filePath,
232241
});
233242

@@ -337,7 +346,7 @@ export default function ArenaWindow({ onClose, isStandaloneWindow = false }: Are
337346
console.log(`[Arena Serial] Final API key length: ${apiKey.length}`);
338347

339348
// 加载 runtime 并替换模型
340-
const runtime = await invoke("load_prompt_runtime", {
349+
const runtime = await invoke<PromptRuntime>("load_prompt_runtime", {
341350
filePath: filePath,
342351
});
343352

@@ -595,7 +604,7 @@ export default function ArenaWindow({ onClose, isStandaloneWindow = false }: Are
595604
}
596605

597606
// 加载 runtime 并替换模型
598-
const runtime = await invoke("load_prompt_runtime", {
607+
const runtime = await invoke<PromptRuntime>("load_prompt_runtime", {
599608
filePath: filePath,
600609
});
601610

0 commit comments

Comments
 (0)