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
60 lines
1.2 KiB
TypeScript
60 lines
1.2 KiB
TypeScript
import {
|
|
isMessageItem,
|
|
isFunctionCallItem,
|
|
isWebSearchCallItem,
|
|
AnyResponseItem,
|
|
} from "../utils/item-types";
|
|
import { MessageItemComponent } from "./message-item";
|
|
import { FunctionCallItemComponent } from "./function-call-item";
|
|
import { WebSearchItemComponent } from "./web-search-item";
|
|
import { GenericItemComponent } from "./generic-item";
|
|
|
|
interface ItemRendererProps {
|
|
item: AnyResponseItem;
|
|
index: number;
|
|
keyPrefix: string;
|
|
defaultRole?: string;
|
|
}
|
|
|
|
export function ItemRenderer({
|
|
item,
|
|
index,
|
|
keyPrefix,
|
|
defaultRole = "unknown",
|
|
}: ItemRendererProps) {
|
|
if (isMessageItem(item)) {
|
|
return (
|
|
<MessageItemComponent
|
|
item={item}
|
|
index={index}
|
|
keyPrefix={keyPrefix}
|
|
defaultRole={defaultRole}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (isFunctionCallItem(item)) {
|
|
return (
|
|
<FunctionCallItemComponent
|
|
item={item}
|
|
index={index}
|
|
keyPrefix={keyPrefix}
|
|
/>
|
|
);
|
|
}
|
|
|
|
if (isWebSearchCallItem(item)) {
|
|
return (
|
|
<WebSearchItemComponent item={item} index={index} keyPrefix={keyPrefix} />
|
|
);
|
|
}
|
|
|
|
// Fallback to generic item for unknown types
|
|
return (
|
|
<GenericItemComponent
|
|
item={item as any}
|
|
index={index}
|
|
keyPrefix={keyPrefix}
|
|
/>
|
|
);
|
|
}
|