diff --git a/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/[contentId]/page.tsx b/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/[contentId]/page.tsx index 5edeff0c8..d58de3085 100644 --- a/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/[contentId]/page.tsx +++ b/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/[contentId]/page.tsx @@ -31,7 +31,7 @@ export default function ContentDetailPage() { const contentId = params.contentId as string; const client = useAuthClient(); - const getTextFromContent = (content: any): string => { + const getTextFromContent = (content: unknown): string => { if (typeof content === "string") { return content; } else if (content && content.type === "text") { @@ -47,7 +47,9 @@ export default function ContentDetailPage() { const [error, setError] = useState(null); const [isEditing, setIsEditing] = useState(false); const [editedContent, setEditedContent] = useState(""); - const [editedMetadata, setEditedMetadata] = useState>({}); + const [editedMetadata, setEditedMetadata] = useState>( + {} + ); const [isEditingEmbedding, setIsEditingEmbedding] = useState(false); const [editedEmbedding, setEditedEmbedding] = useState([]); @@ -98,7 +100,8 @@ export default function ContentDetailPage() { if (!content) return; try { - const updates: { content?: string; metadata?: Record } = {}; + const updates: { content?: string; metadata?: Record } = + {}; if (editedContent !== getTextFromContent(content.content)) { updates.content = editedContent; diff --git a/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/page.tsx b/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/page.tsx index 594ef72a6..0283db9e7 100644 --- a/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/page.tsx +++ b/llama_stack/ui/app/logs/vector-stores/[id]/files/[fileId]/contents/page.tsx @@ -39,7 +39,7 @@ export default function ContentsListPage() { const fileId = params.fileId as string; const client = useAuthClient(); - const getTextFromContent = (content: any): string => { + const getTextFromContent = (content: unknown): string => { if (typeof content === "string") { return content; } else if (content && content.type === "text") { @@ -52,10 +52,8 @@ export default function ContentsListPage() { const [file, setFile] = useState(null); const [contents, setContents] = useState([]); const [isLoadingStore, setIsLoadingStore] = useState(true); - const [isLoadingFile, setIsLoadingFile] = useState(true); const [isLoadingContents, setIsLoadingContents] = useState(true); const [errorStore, setErrorStore] = useState(null); - const [errorFile, setErrorFile] = useState(null); const [errorContents, setErrorContents] = useState(null); useEffect(() => { diff --git a/llama_stack/ui/app/logs/vector-stores/[id]/page.tsx b/llama_stack/ui/app/logs/vector-stores/[id]/page.tsx index d2e974a63..cad50506c 100644 --- a/llama_stack/ui/app/logs/vector-stores/[id]/page.tsx +++ b/llama_stack/ui/app/logs/vector-stores/[id]/page.tsx @@ -1,7 +1,7 @@ "use client"; import { useEffect, useState } from "react"; -import { useParams, useRouter } from "next/navigation"; +import { useParams } from "next/navigation"; import { useAuthClient } from "@/hooks/use-auth-client"; import type { VectorStore } from "llama-stack-client/resources/vector-stores/vector-stores"; import type { VectorStoreFile } from "llama-stack-client/resources/vector-stores/files"; @@ -11,7 +11,6 @@ export default function VectorStoreDetailPage() { const params = useParams(); const id = params.id as string; const client = useAuthClient(); - const router = useRouter(); const [store, setStore] = useState(null); const [files, setFiles] = useState([]); @@ -53,8 +52,8 @@ export default function VectorStoreDetailPage() { setIsLoadingFiles(true); setErrorFiles(null); try { - const result = await client.vectorStores.files.list(id as any); - setFiles((result as any).data); + const result = await client.vectorStores.files.list(id); + setFiles((result as { data: VectorStoreFile[] }).data); } catch (err) { setErrorFiles( err instanceof Error ? err : new Error("Failed to load files.") @@ -64,7 +63,7 @@ export default function VectorStoreDetailPage() { } }; fetchFiles(); - }, [id]); + }, [id, client.vectorStores.files]); return ( [0]); return response as ListVectorStoresResponse; }, errorMessagePrefix: "vector stores", diff --git a/llama_stack/ui/components/chat-completions/chat-completion-detail.tsx b/llama_stack/ui/components/chat-completions/chat-completion-detail.tsx index 583a09981..0d11d2444 100644 --- a/llama_stack/ui/components/chat-completions/chat-completion-detail.tsx +++ b/llama_stack/ui/components/chat-completions/chat-completion-detail.tsx @@ -60,7 +60,7 @@ export function ChatCompletionDetailView({ im.tool_calls.length > 0 ) ? completion.choices[0].message.tool_calls.map( - (toolCall: any, index: number) => { + (toolCall: { function?: { name?: string } }, index: number) => { const assistantToolCallMessage: ChatMessage = { role: "assistant", tool_calls: [toolCall], @@ -89,7 +89,7 @@ export function ChatCompletionDetailView({ /> ) : (

- No message found in assistant's choice. + No message found in assistant's choice.

)} @@ -120,13 +120,18 @@ export function ChatCompletionDetailView({ value={
    - {toolCalls.map((toolCall: any, index: number) => ( -
  • - - {toolCall.function?.name || "N/A"} - -
  • - ))} + {toolCalls.map( + ( + toolCall: { function?: { name?: string } }, + index: number + ) => ( +
  • + + {toolCall.function?.name || "N/A"} + +
  • + ) + )}
} diff --git a/llama_stack/ui/components/chat-completions/chat-completions-table.tsx b/llama_stack/ui/components/chat-completions/chat-completions-table.tsx index d30ec1538..64e8167f2 100644 --- a/llama_stack/ui/components/chat-completions/chat-completions-table.tsx +++ b/llama_stack/ui/components/chat-completions/chat-completions-table.tsx @@ -5,6 +5,7 @@ import { UsePaginationOptions, ListChatCompletionsResponse, } from "@/lib/types"; +import { ListChatCompletionsParams } from "@/lib/llama-stack-client"; import { LogsTable, LogTableRow } from "@/components/logs/logs-table"; import { extractTextFromContentPart, @@ -45,7 +46,7 @@ export function ChatCompletionsTable({ limit: params.limit, ...(params.model && { model: params.model }), ...(params.order && { order: params.order }), - } as any); + } as ListChatCompletionsParams); return response as ListChatCompletionsResponse; }; diff --git a/llama_stack/ui/components/chat-completions/chat-messasge-item.tsx b/llama_stack/ui/components/chat-completions/chat-messasge-item.tsx index 6170e816e..de097e630 100644 --- a/llama_stack/ui/components/chat-completions/chat-messasge-item.tsx +++ b/llama_stack/ui/components/chat-completions/chat-messasge-item.tsx @@ -37,21 +37,26 @@ export function ChatMessageItem({ message }: ChatMessageItemProps) { ) { return ( <> - {message.tool_calls.map((toolCall: any, index: number) => { - const formattedToolCall = formatToolCallToString(toolCall); - const toolCallContent = ( - - {formattedToolCall || "Error: Could not display tool call"} - - ); - return ( - - ); - })} + {message.tool_calls.map( + ( + toolCall: { function?: { name?: string; arguments?: unknown } }, + index: number + ) => { + const formattedToolCall = formatToolCallToString(toolCall); + const toolCallContent = ( + + {formattedToolCall || "Error: Could not display tool call"} + + ); + return ( + + ); + } + )} ); } else { diff --git a/llama_stack/ui/components/chat-playground/chat-message.tsx b/llama_stack/ui/components/chat-playground/chat-message.tsx index 02e6933cc..84c798e29 100644 --- a/llama_stack/ui/components/chat-playground/chat-message.tsx +++ b/llama_stack/ui/components/chat-playground/chat-message.tsx @@ -77,7 +77,7 @@ interface ToolResult { toolName: string; result: { __cancelled?: boolean; - [key: string]: any; + [key: string]: unknown; }; } @@ -101,7 +101,7 @@ interface TextPart { // For compatibility with AI SDK types, not used interface SourcePart { type: "source"; - source?: any; + source?: unknown; } interface FilePart { diff --git a/llama_stack/ui/components/chat-playground/chat.tsx b/llama_stack/ui/components/chat-playground/chat.tsx index de4860f22..023bf0728 100644 --- a/llama_stack/ui/components/chat-playground/chat.tsx +++ b/llama_stack/ui/components/chat-playground/chat.tsx @@ -33,7 +33,7 @@ interface ChatPropsBase { messageId: string, rating: "thumbs-up" | "thumbs-down" ) => void; - setMessages?: (messages: any[]) => void; + setMessages?: (messages: Message[]) => void; transcribeAudio?: (blob: Blob) => Promise; } @@ -113,27 +113,32 @@ export function Chat({ } if (lastAssistantMessage.parts && lastAssistantMessage.parts.length > 0) { - const updatedParts = lastAssistantMessage.parts.map((part: any) => { - if ( - part.type === "tool-invocation" && - part.toolInvocation && - part.toolInvocation.state === "call" - ) { - needsUpdate = true; - return { - ...part, - toolInvocation: { - ...part.toolInvocation, - state: "result", - result: { - content: "Tool execution was cancelled", - __cancelled: true, + const updatedParts = lastAssistantMessage.parts.map( + (part: { + type: string; + toolInvocation?: { state: string; toolName: string }; + }) => { + if ( + part.type === "tool-invocation" && + part.toolInvocation && + part.toolInvocation.state === "call" + ) { + needsUpdate = true; + return { + ...part, + toolInvocation: { + ...part.toolInvocation, + state: "result", + result: { + content: "Tool execution was cancelled", + __cancelled: true, + }, }, - }, - }; + }; + } + return part; } - return part; - }); + ); if (needsUpdate) { updatedMessage = { @@ -316,10 +321,10 @@ export const ChatForm = forwardRef( const [files, setFiles] = useState(null); const onSubmit = (event: React.FormEvent) => { - // if (isPending) { - // event.preventDefault() - // return - // } + if (isPending) { + event.preventDefault(); + return; + } if (!files) { handleSubmit(event); diff --git a/llama_stack/ui/components/chat-playground/markdown-renderer.tsx b/llama_stack/ui/components/chat-playground/markdown-renderer.tsx index a0e4227a6..bc6bf5122 100644 --- a/llama_stack/ui/components/chat-playground/markdown-renderer.tsx +++ b/llama_stack/ui/components/chat-playground/markdown-renderer.tsx @@ -26,7 +26,7 @@ interface HighlightedPre extends React.HTMLAttributes { const HighlightedPre = React.memo( ({ children, language, ...props }: HighlightedPre) => { - const [tokens, setTokens] = useState(null); + const [tokens, setTokens] = useState(null); const [isSupported, setIsSupported] = useState(false); useEffect(() => { @@ -57,7 +57,7 @@ const HighlightedPre = React.memo( if (mounted) { setTokens(highlightedTokens); } - } catch (error) { + } catch { if (mounted) { setIsSupported(false); } @@ -155,7 +155,7 @@ const CodeBlock = ({ ); }; -function childrenTakeAllStringContents(element: any): string { +function childrenTakeAllStringContents(element: unknown): string { if (typeof element === "string") { return element; } @@ -184,7 +184,13 @@ const COMPONENTS = { strong: withClass("strong", "font-semibold"), a: withClass("a", "text-primary underline underline-offset-2"), blockquote: withClass("blockquote", "border-l-2 border-primary pl-4"), - code: ({ children, className, node, ...rest }: any) => { + code: ({ + children, + className, + }: { + children: React.ReactNode; + className?: string; + }) => { const match = /language-(\w+)/.exec(className || ""); return match ? ( @@ -201,7 +207,7 @@ const COMPONENTS = { ); }, - pre: ({ children }: any) => children, + pre: ({ children }: { children: React.ReactNode }) => children, ol: withClass("ol", "list-decimal space-y-2 pl-6"), ul: withClass("ul", "list-disc space-y-2 pl-6"), li: withClass("li", "my-1.5"), @@ -223,7 +229,7 @@ const COMPONENTS = { }; function withClass(Tag: keyof JSX.IntrinsicElements, classes: string) { - const Component = ({ node, ...props }: any) => ( + const Component = ({ ...props }: Record) => ( ); Component.displayName = Tag; diff --git a/llama_stack/ui/components/chat-playground/message-input.tsx b/llama_stack/ui/components/chat-playground/message-input.tsx index 57fac0ab4..8cfa73b30 100644 --- a/llama_stack/ui/components/chat-playground/message-input.tsx +++ b/llama_stack/ui/components/chat-playground/message-input.tsx @@ -62,7 +62,9 @@ export function MessageInput({ } = useAudioRecording({ transcribeAudio, onTranscriptionComplete: text => { - props.onChange?.({ target: { value: text } } as any); + props.onChange?.({ + target: { value: text }, + } as React.ChangeEvent); }, }); diff --git a/llama_stack/ui/components/layout/detail-layout.tsx b/llama_stack/ui/components/layout/detail-layout.tsx index 3013195a2..ed5edd127 100644 --- a/llama_stack/ui/components/layout/detail-layout.tsx +++ b/llama_stack/ui/components/layout/detail-layout.tsx @@ -2,7 +2,7 @@ import React from "react"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Skeleton } from "@/components/ui/skeleton"; -export function DetailLoadingView({ title }: { title: string }) { +export function DetailLoadingView() { return ( <> {/* Title Skeleton */} diff --git a/llama_stack/ui/components/responses/items/item-renderer.tsx b/llama_stack/ui/components/responses/items/item-renderer.tsx index 8f65d50c4..5f16d9120 100644 --- a/llama_stack/ui/components/responses/items/item-renderer.tsx +++ b/llama_stack/ui/components/responses/items/item-renderer.tsx @@ -52,7 +52,7 @@ export function ItemRenderer({ // Fallback to generic item for unknown types return ( } index={index} keyPrefix={keyPrefix} /> diff --git a/llama_stack/ui/components/responses/responses-detail.test.tsx b/llama_stack/ui/components/responses/responses-detail.test.tsx index 4c14db340..c0f348cad 100644 --- a/llama_stack/ui/components/responses/responses-detail.test.tsx +++ b/llama_stack/ui/components/responses/responses-detail.test.tsx @@ -616,7 +616,7 @@ describe("ResponseDetailView", () => { type: "unknown_type", custom_field: "custom_value", data: { nested: "object" }, - } as any, + } as unknown, ], input: [], }; @@ -666,7 +666,7 @@ describe("ResponseDetailView", () => { role: "assistant", call_id: "call_123", content: "sunny and warm", - } as any, // Using any to bypass the type restriction for this test + } as unknown, // Using any to bypass the type restriction for this test ], input: [], }; @@ -706,7 +706,7 @@ describe("ResponseDetailView", () => { status: "completed", call_id: "call_123", output: "sunny and warm", - } as any, // Using any to bypass the type restriction for this test + } as unknown, ], input: [], }; diff --git a/llama_stack/ui/components/responses/responses-table.test.tsx b/llama_stack/ui/components/responses/responses-table.test.tsx index 4936a7be1..37eaed543 100644 --- a/llama_stack/ui/components/responses/responses-table.test.tsx +++ b/llama_stack/ui/components/responses/responses-table.test.tsx @@ -565,7 +565,7 @@ describe("ResponsesTable", () => { id: "unknown_123", status: "completed", custom_field: "custom_value", - } as any, + } as unknown, ], input: [{ type: "message", content: "input" }], }; @@ -594,7 +594,7 @@ describe("ResponsesTable", () => { { type: "unknown_type", data: "some data", - } as any, + } as unknown, ], input: [{ type: "message", content: "input" }], }; diff --git a/llama_stack/ui/components/responses/responses-table.tsx b/llama_stack/ui/components/responses/responses-table.tsx index dc8edd246..0c0f8e56b 100644 --- a/llama_stack/ui/components/responses/responses-table.tsx +++ b/llama_stack/ui/components/responses/responses-table.tsx @@ -56,7 +56,9 @@ function getInputText(response: OpenAIResponse): string { } function getOutputText(response: OpenAIResponse): string { - const firstMessage = response.output.find(item => isMessageItem(item as any)); + const firstMessage = response.output.find(item => + isMessageItem(item as Record) + ); if (firstMessage) { const content = extractContentFromItem(firstMessage as MessageItem); if (content) { @@ -65,14 +67,14 @@ function getOutputText(response: OpenAIResponse): string { } const functionCall = response.output.find(item => - isFunctionCallItem(item as any) + isFunctionCallItem(item as Record) ); if (functionCall) { return formatFunctionCall(functionCall as FunctionCallItem); } const webSearchCall = response.output.find(item => - isWebSearchCallItem(item as any) + isWebSearchCallItem(item as Record) ); if (webSearchCall) { return formatWebSearchCall(webSearchCall as WebSearchCallItem); @@ -136,7 +138,7 @@ export function ResponsesTable({ paginationOptions }: ResponsesTableProps) { limit: params.limit, ...(params.model && { model: params.model }), ...(params.order && { order: params.order }), - } as any); + } as Parameters[0]); const listResponse = response as ResponseListResponse; diff --git a/llama_stack/ui/components/responses/utils/item-types.ts b/llama_stack/ui/components/responses/utils/item-types.ts index 72f31cf38..1c1ca2cb1 100644 --- a/llama_stack/ui/components/responses/utils/item-types.ts +++ b/llama_stack/ui/components/responses/utils/item-types.ts @@ -56,6 +56,6 @@ export function isFunctionCallOutputItem( return ( item.type === "function_call_output" && "call_id" in item && - typeof (item as any).call_id === "string" + typeof (item as Record).call_id === "string" ); } diff --git a/llama_stack/ui/lib/contents-api.ts b/llama_stack/ui/lib/contents-api.ts index da6d0d324..f4920f3db 100644 --- a/llama_stack/ui/lib/contents-api.ts +++ b/llama_stack/ui/lib/contents-api.ts @@ -11,7 +11,7 @@ export interface VectorStoreContentItem { vector_store_id: string; file_id: string; content: VectorStoreContent; - metadata: Record; + metadata: Record; embedding?: number[]; } @@ -54,20 +54,11 @@ export class ContentsAPI { return targetContent; } - async updateContent( - vectorStoreId: string, - fileId: string, - contentId: string, - updates: { content?: string; metadata?: Record } - ): Promise { + async updateContent(): Promise { throw new Error("Individual content updates not yet implemented in API"); } - async deleteContent( - vectorStoreId: string, - fileId: string, - contentId: string - ): Promise { + async deleteContent(): Promise { throw new Error("Individual content deletion not yet implemented in API"); } @@ -88,7 +79,7 @@ export class ContentsAPI { const contentItems: VectorStoreContentItem[] = []; fileContents.content.forEach((content, contentIndex) => { - const rawContent = content as any; + const rawContent = content as Record; // Extract actual fields from the API response const embedding = rawContent.embedding || undefined; diff --git a/llama_stack/ui/lib/format-message-content.test.ts b/llama_stack/ui/lib/format-message-content.test.ts index e082eec26..18abbee39 100644 --- a/llama_stack/ui/lib/format-message-content.test.ts +++ b/llama_stack/ui/lib/format-message-content.test.ts @@ -53,7 +53,7 @@ describe("extractTextFromContentPart", () => { }); it("should handle arrays with plain strings", () => { - const content = ["This is", " a test."] as any; + const content = ["This is", " a test."] as unknown; expect(extractTextFromContentPart(content)).toBe("This is a test."); }); @@ -65,7 +65,7 @@ describe("extractTextFromContentPart", () => { null, undefined, { type: "text", noTextProperty: true }, - ] as any; + ] as unknown; expect(extractTextFromContentPart(content)).toBe("Valid"); }); @@ -75,7 +75,7 @@ describe("extractTextFromContentPart", () => { "Just a string.", { type: "image_url", image_url: { url: "http://example.com/image.png" } }, { type: "text", text: "Last part." }, - ] as any; + ] as unknown; expect(extractTextFromContentPart(content)).toBe( "First part. Just a string. [Image] Last part." ); @@ -83,7 +83,9 @@ describe("extractTextFromContentPart", () => { }); describe("extractDisplayableText (composite function)", () => { - const mockFormatToolCallToString = (toolCall: any) => { + const mockFormatToolCallToString = (toolCall: { + function?: { name?: string; arguments?: unknown }; + }) => { if (!toolCall || !toolCall.function || !toolCall.function.name) return ""; const args = toolCall.function.arguments ? JSON.stringify(toolCall.function.arguments) diff --git a/llama_stack/ui/lib/format-tool-call.tsx b/llama_stack/ui/lib/format-tool-call.tsx index f6a286a6e..ec1bdce38 100644 --- a/llama_stack/ui/lib/format-tool-call.tsx +++ b/llama_stack/ui/lib/format-tool-call.tsx @@ -5,7 +5,9 @@ * with `name` and `arguments`. * @returns A formatted string or an empty string if data is malformed. */ -export function formatToolCallToString(toolCall: any): string { +export function formatToolCallToString(toolCall: { + function?: { name?: string; arguments?: unknown }; +}): string { if ( !toolCall || !toolCall.function || @@ -24,7 +26,7 @@ export function formatToolCallToString(toolCall: any): string { } else { try { argsString = JSON.stringify(args); - } catch (error) { + } catch { return ""; } }