mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-06-27 18:50:41 +00:00
# What does this PR do? * Add responses list and detail views * Refactored components to be shared as much as possible between chat completions and responses ## Test Plan <img width="2014" alt="image" src="https://github.com/user-attachments/assets/6dee12ea-8876-4351-a6eb-2338058466ef" /> <img width="2021" alt="image" src="https://github.com/user-attachments/assets/6c7c71b8-25b7-4199-9c57-6960be5580c8" /> added tests
58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import { useParams } from "next/navigation";
|
|
import { ChatCompletion } from "@/lib/types";
|
|
import { ChatCompletionDetailView } from "@/components/chat-completions/chat-completion-detail";
|
|
import { client } from "@/lib/client";
|
|
|
|
export default function ChatCompletionDetailPage() {
|
|
const params = useParams();
|
|
const id = params.id as string;
|
|
|
|
const [completionDetail, setCompletionDetail] =
|
|
useState<ChatCompletion | null>(null);
|
|
const [isLoading, setIsLoading] = useState<boolean>(true);
|
|
const [error, setError] = useState<Error | null>(null);
|
|
|
|
useEffect(() => {
|
|
if (!id) {
|
|
setError(new Error("Completion ID is missing."));
|
|
setIsLoading(false);
|
|
return;
|
|
}
|
|
|
|
const fetchCompletionDetail = async () => {
|
|
setIsLoading(true);
|
|
setError(null);
|
|
setCompletionDetail(null);
|
|
try {
|
|
const response = await client.chat.completions.retrieve(id);
|
|
setCompletionDetail(response as ChatCompletion);
|
|
} catch (err) {
|
|
console.error(
|
|
`Error fetching chat completion detail for ID ${id}:`,
|
|
err,
|
|
);
|
|
setError(
|
|
err instanceof Error
|
|
? err
|
|
: new Error("Failed to fetch completion detail"),
|
|
);
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
};
|
|
|
|
fetchCompletionDetail();
|
|
}, [id]);
|
|
|
|
return (
|
|
<ChatCompletionDetailView
|
|
completion={completionDetail}
|
|
isLoading={isLoading}
|
|
error={error}
|
|
id={id}
|
|
/>
|
|
);
|
|
}
|