mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-08-15 06:00:48 +00:00
fixing linter
Signed-off-by: Francisco Javier Arceo <farceo@redhat.com>
This commit is contained in:
parent
2fb07a7034
commit
d3097ecc73
20 changed files with 122 additions and 104 deletions
|
@ -31,7 +31,7 @@ export default function ContentDetailPage() {
|
||||||
const contentId = params.contentId as string;
|
const contentId = params.contentId as string;
|
||||||
const client = useAuthClient();
|
const client = useAuthClient();
|
||||||
|
|
||||||
const getTextFromContent = (content: any): string => {
|
const getTextFromContent = (content: unknown): string => {
|
||||||
if (typeof content === "string") {
|
if (typeof content === "string") {
|
||||||
return content;
|
return content;
|
||||||
} else if (content && content.type === "text") {
|
} else if (content && content.type === "text") {
|
||||||
|
@ -47,7 +47,9 @@ export default function ContentDetailPage() {
|
||||||
const [error, setError] = useState<Error | null>(null);
|
const [error, setError] = useState<Error | null>(null);
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const [editedContent, setEditedContent] = useState("");
|
const [editedContent, setEditedContent] = useState("");
|
||||||
const [editedMetadata, setEditedMetadata] = useState<Record<string, any>>({});
|
const [editedMetadata, setEditedMetadata] = useState<Record<string, unknown>>(
|
||||||
|
{}
|
||||||
|
);
|
||||||
const [isEditingEmbedding, setIsEditingEmbedding] = useState(false);
|
const [isEditingEmbedding, setIsEditingEmbedding] = useState(false);
|
||||||
const [editedEmbedding, setEditedEmbedding] = useState<number[]>([]);
|
const [editedEmbedding, setEditedEmbedding] = useState<number[]>([]);
|
||||||
|
|
||||||
|
@ -98,7 +100,8 @@ export default function ContentDetailPage() {
|
||||||
if (!content) return;
|
if (!content) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const updates: { content?: string; metadata?: Record<string, any> } = {};
|
const updates: { content?: string; metadata?: Record<string, unknown> } =
|
||||||
|
{};
|
||||||
|
|
||||||
if (editedContent !== getTextFromContent(content.content)) {
|
if (editedContent !== getTextFromContent(content.content)) {
|
||||||
updates.content = editedContent;
|
updates.content = editedContent;
|
||||||
|
|
|
@ -39,7 +39,7 @@ export default function ContentsListPage() {
|
||||||
const fileId = params.fileId as string;
|
const fileId = params.fileId as string;
|
||||||
const client = useAuthClient();
|
const client = useAuthClient();
|
||||||
|
|
||||||
const getTextFromContent = (content: any): string => {
|
const getTextFromContent = (content: unknown): string => {
|
||||||
if (typeof content === "string") {
|
if (typeof content === "string") {
|
||||||
return content;
|
return content;
|
||||||
} else if (content && content.type === "text") {
|
} else if (content && content.type === "text") {
|
||||||
|
@ -52,10 +52,8 @@ export default function ContentsListPage() {
|
||||||
const [file, setFile] = useState<VectorStoreFile | null>(null);
|
const [file, setFile] = useState<VectorStoreFile | null>(null);
|
||||||
const [contents, setContents] = useState<VectorStoreContentItem[]>([]);
|
const [contents, setContents] = useState<VectorStoreContentItem[]>([]);
|
||||||
const [isLoadingStore, setIsLoadingStore] = useState(true);
|
const [isLoadingStore, setIsLoadingStore] = useState(true);
|
||||||
const [isLoadingFile, setIsLoadingFile] = useState(true);
|
|
||||||
const [isLoadingContents, setIsLoadingContents] = useState(true);
|
const [isLoadingContents, setIsLoadingContents] = useState(true);
|
||||||
const [errorStore, setErrorStore] = useState<Error | null>(null);
|
const [errorStore, setErrorStore] = useState<Error | null>(null);
|
||||||
const [errorFile, setErrorFile] = useState<Error | null>(null);
|
|
||||||
const [errorContents, setErrorContents] = useState<Error | null>(null);
|
const [errorContents, setErrorContents] = useState<Error | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useParams, useRouter } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import { useAuthClient } from "@/hooks/use-auth-client";
|
import { useAuthClient } from "@/hooks/use-auth-client";
|
||||||
import type { VectorStore } from "llama-stack-client/resources/vector-stores/vector-stores";
|
import type { VectorStore } from "llama-stack-client/resources/vector-stores/vector-stores";
|
||||||
import type { VectorStoreFile } from "llama-stack-client/resources/vector-stores/files";
|
import type { VectorStoreFile } from "llama-stack-client/resources/vector-stores/files";
|
||||||
|
@ -11,7 +11,6 @@ export default function VectorStoreDetailPage() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const id = params.id as string;
|
const id = params.id as string;
|
||||||
const client = useAuthClient();
|
const client = useAuthClient();
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const [store, setStore] = useState<VectorStore | null>(null);
|
const [store, setStore] = useState<VectorStore | null>(null);
|
||||||
const [files, setFiles] = useState<VectorStoreFile[]>([]);
|
const [files, setFiles] = useState<VectorStoreFile[]>([]);
|
||||||
|
@ -53,8 +52,8 @@ export default function VectorStoreDetailPage() {
|
||||||
setIsLoadingFiles(true);
|
setIsLoadingFiles(true);
|
||||||
setErrorFiles(null);
|
setErrorFiles(null);
|
||||||
try {
|
try {
|
||||||
const result = await client.vectorStores.files.list(id as any);
|
const result = await client.vectorStores.files.list(id);
|
||||||
setFiles((result as any).data);
|
setFiles((result as { data: VectorStoreFile[] }).data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
setErrorFiles(
|
setErrorFiles(
|
||||||
err instanceof Error ? err : new Error("Failed to load files.")
|
err instanceof Error ? err : new Error("Failed to load files.")
|
||||||
|
@ -64,7 +63,7 @@ export default function VectorStoreDetailPage() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchFiles();
|
fetchFiles();
|
||||||
}, [id]);
|
}, [id, client.vectorStores.files]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<VectorStoreDetailView
|
<VectorStoreDetailView
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useAuthClient } from "@/hooks/use-auth-client";
|
|
||||||
import type {
|
import type {
|
||||||
ListVectorStoresResponse,
|
ListVectorStoresResponse,
|
||||||
VectorStore,
|
VectorStore,
|
||||||
|
@ -12,7 +11,6 @@ import { Button } from "@/components/ui/button";
|
||||||
import {
|
import {
|
||||||
Table,
|
Table,
|
||||||
TableBody,
|
TableBody,
|
||||||
TableCaption,
|
|
||||||
TableCell,
|
TableCell,
|
||||||
TableHead,
|
TableHead,
|
||||||
TableHeader,
|
TableHeader,
|
||||||
|
@ -21,7 +19,6 @@ import {
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
export default function VectorStoresPage() {
|
export default function VectorStoresPage() {
|
||||||
const client = useAuthClient();
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const {
|
const {
|
||||||
data: stores,
|
data: stores,
|
||||||
|
@ -37,7 +34,7 @@ export default function VectorStoresPage() {
|
||||||
after: params.after,
|
after: params.after,
|
||||||
limit: params.limit,
|
limit: params.limit,
|
||||||
order: params.order,
|
order: params.order,
|
||||||
} as any);
|
} as Parameters<typeof client.vectorStores.list>[0]);
|
||||||
return response as ListVectorStoresResponse;
|
return response as ListVectorStoresResponse;
|
||||||
},
|
},
|
||||||
errorMessagePrefix: "vector stores",
|
errorMessagePrefix: "vector stores",
|
||||||
|
|
|
@ -60,7 +60,7 @@ export function ChatCompletionDetailView({
|
||||||
im.tool_calls.length > 0
|
im.tool_calls.length > 0
|
||||||
)
|
)
|
||||||
? completion.choices[0].message.tool_calls.map(
|
? completion.choices[0].message.tool_calls.map(
|
||||||
(toolCall: any, index: number) => {
|
(toolCall: { function?: { name?: string } }, index: number) => {
|
||||||
const assistantToolCallMessage: ChatMessage = {
|
const assistantToolCallMessage: ChatMessage = {
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
tool_calls: [toolCall],
|
tool_calls: [toolCall],
|
||||||
|
@ -89,7 +89,7 @@ export function ChatCompletionDetailView({
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<p className="text-gray-500 italic text-sm">
|
<p className="text-gray-500 italic text-sm">
|
||||||
No message found in assistant's choice.
|
No message found in assistant's choice.
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
@ -120,13 +120,18 @@ export function ChatCompletionDetailView({
|
||||||
value={
|
value={
|
||||||
<div>
|
<div>
|
||||||
<ul className="list-disc list-inside pl-4 mt-1">
|
<ul className="list-disc list-inside pl-4 mt-1">
|
||||||
{toolCalls.map((toolCall: any, index: number) => (
|
{toolCalls.map(
|
||||||
|
(
|
||||||
|
toolCall: { function?: { name?: string } },
|
||||||
|
index: number
|
||||||
|
) => (
|
||||||
<li key={index}>
|
<li key={index}>
|
||||||
<span className="text-gray-900 font-medium">
|
<span className="text-gray-900 font-medium">
|
||||||
{toolCall.function?.name || "N/A"}
|
{toolCall.function?.name || "N/A"}
|
||||||
</span>
|
</span>
|
||||||
</li>
|
</li>
|
||||||
))}
|
)
|
||||||
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {
|
||||||
UsePaginationOptions,
|
UsePaginationOptions,
|
||||||
ListChatCompletionsResponse,
|
ListChatCompletionsResponse,
|
||||||
} from "@/lib/types";
|
} from "@/lib/types";
|
||||||
|
import { ListChatCompletionsParams } from "@/lib/llama-stack-client";
|
||||||
import { LogsTable, LogTableRow } from "@/components/logs/logs-table";
|
import { LogsTable, LogTableRow } from "@/components/logs/logs-table";
|
||||||
import {
|
import {
|
||||||
extractTextFromContentPart,
|
extractTextFromContentPart,
|
||||||
|
@ -45,7 +46,7 @@ export function ChatCompletionsTable({
|
||||||
limit: params.limit,
|
limit: params.limit,
|
||||||
...(params.model && { model: params.model }),
|
...(params.model && { model: params.model }),
|
||||||
...(params.order && { order: params.order }),
|
...(params.order && { order: params.order }),
|
||||||
} as any);
|
} as ListChatCompletionsParams);
|
||||||
|
|
||||||
return response as ListChatCompletionsResponse;
|
return response as ListChatCompletionsResponse;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,7 +37,11 @@ export function ChatMessageItem({ message }: ChatMessageItemProps) {
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{message.tool_calls.map((toolCall: any, index: number) => {
|
{message.tool_calls.map(
|
||||||
|
(
|
||||||
|
toolCall: { function?: { name?: string; arguments?: unknown } },
|
||||||
|
index: number
|
||||||
|
) => {
|
||||||
const formattedToolCall = formatToolCallToString(toolCall);
|
const formattedToolCall = formatToolCallToString(toolCall);
|
||||||
const toolCallContent = (
|
const toolCallContent = (
|
||||||
<ToolCallBlock>
|
<ToolCallBlock>
|
||||||
|
@ -51,7 +55,8 @@ export function ChatMessageItem({ message }: ChatMessageItemProps) {
|
||||||
content={toolCallContent}
|
content={toolCallContent}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
}
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -77,7 +77,7 @@ interface ToolResult {
|
||||||
toolName: string;
|
toolName: string;
|
||||||
result: {
|
result: {
|
||||||
__cancelled?: boolean;
|
__cancelled?: boolean;
|
||||||
[key: string]: any;
|
[key: string]: unknown;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ interface TextPart {
|
||||||
// For compatibility with AI SDK types, not used
|
// For compatibility with AI SDK types, not used
|
||||||
interface SourcePart {
|
interface SourcePart {
|
||||||
type: "source";
|
type: "source";
|
||||||
source?: any;
|
source?: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface FilePart {
|
interface FilePart {
|
||||||
|
|
|
@ -33,7 +33,7 @@ interface ChatPropsBase {
|
||||||
messageId: string,
|
messageId: string,
|
||||||
rating: "thumbs-up" | "thumbs-down"
|
rating: "thumbs-up" | "thumbs-down"
|
||||||
) => void;
|
) => void;
|
||||||
setMessages?: (messages: any[]) => void;
|
setMessages?: (messages: Message[]) => void;
|
||||||
transcribeAudio?: (blob: Blob) => Promise<string>;
|
transcribeAudio?: (blob: Blob) => Promise<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,7 +113,11 @@ export function Chat({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastAssistantMessage.parts && lastAssistantMessage.parts.length > 0) {
|
if (lastAssistantMessage.parts && lastAssistantMessage.parts.length > 0) {
|
||||||
const updatedParts = lastAssistantMessage.parts.map((part: any) => {
|
const updatedParts = lastAssistantMessage.parts.map(
|
||||||
|
(part: {
|
||||||
|
type: string;
|
||||||
|
toolInvocation?: { state: string; toolName: string };
|
||||||
|
}) => {
|
||||||
if (
|
if (
|
||||||
part.type === "tool-invocation" &&
|
part.type === "tool-invocation" &&
|
||||||
part.toolInvocation &&
|
part.toolInvocation &&
|
||||||
|
@ -133,7 +137,8 @@ export function Chat({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return part;
|
return part;
|
||||||
});
|
}
|
||||||
|
);
|
||||||
|
|
||||||
if (needsUpdate) {
|
if (needsUpdate) {
|
||||||
updatedMessage = {
|
updatedMessage = {
|
||||||
|
@ -316,10 +321,10 @@ export const ChatForm = forwardRef<HTMLFormElement, ChatFormProps>(
|
||||||
const [files, setFiles] = useState<File[] | null>(null);
|
const [files, setFiles] = useState<File[] | null>(null);
|
||||||
|
|
||||||
const onSubmit = (event: React.FormEvent) => {
|
const onSubmit = (event: React.FormEvent) => {
|
||||||
// if (isPending) {
|
if (isPending) {
|
||||||
// event.preventDefault()
|
event.preventDefault();
|
||||||
// return
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (!files) {
|
if (!files) {
|
||||||
handleSubmit(event);
|
handleSubmit(event);
|
||||||
|
|
|
@ -26,7 +26,7 @@ interface HighlightedPre extends React.HTMLAttributes<HTMLPreElement> {
|
||||||
|
|
||||||
const HighlightedPre = React.memo(
|
const HighlightedPre = React.memo(
|
||||||
({ children, language, ...props }: HighlightedPre) => {
|
({ children, language, ...props }: HighlightedPre) => {
|
||||||
const [tokens, setTokens] = useState<any[] | null>(null);
|
const [tokens, setTokens] = useState<unknown[] | null>(null);
|
||||||
const [isSupported, setIsSupported] = useState(false);
|
const [isSupported, setIsSupported] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -57,7 +57,7 @@ const HighlightedPre = React.memo(
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setTokens(highlightedTokens);
|
setTokens(highlightedTokens);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
setIsSupported(false);
|
setIsSupported(false);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ const CodeBlock = ({
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
function childrenTakeAllStringContents(element: any): string {
|
function childrenTakeAllStringContents(element: unknown): string {
|
||||||
if (typeof element === "string") {
|
if (typeof element === "string") {
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
@ -184,7 +184,13 @@ const COMPONENTS = {
|
||||||
strong: withClass("strong", "font-semibold"),
|
strong: withClass("strong", "font-semibold"),
|
||||||
a: withClass("a", "text-primary underline underline-offset-2"),
|
a: withClass("a", "text-primary underline underline-offset-2"),
|
||||||
blockquote: withClass("blockquote", "border-l-2 border-primary pl-4"),
|
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 || "");
|
const match = /language-(\w+)/.exec(className || "");
|
||||||
return match ? (
|
return match ? (
|
||||||
<CodeBlock className={className} language={match[1]} {...rest}>
|
<CodeBlock className={className} language={match[1]} {...rest}>
|
||||||
|
@ -201,7 +207,7 @@ const COMPONENTS = {
|
||||||
</code>
|
</code>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
pre: ({ children }: any) => children,
|
pre: ({ children }: { children: React.ReactNode }) => children,
|
||||||
ol: withClass("ol", "list-decimal space-y-2 pl-6"),
|
ol: withClass("ol", "list-decimal space-y-2 pl-6"),
|
||||||
ul: withClass("ul", "list-disc space-y-2 pl-6"),
|
ul: withClass("ul", "list-disc space-y-2 pl-6"),
|
||||||
li: withClass("li", "my-1.5"),
|
li: withClass("li", "my-1.5"),
|
||||||
|
@ -223,7 +229,7 @@ const COMPONENTS = {
|
||||||
};
|
};
|
||||||
|
|
||||||
function withClass(Tag: keyof JSX.IntrinsicElements, classes: string) {
|
function withClass(Tag: keyof JSX.IntrinsicElements, classes: string) {
|
||||||
const Component = ({ node, ...props }: any) => (
|
const Component = ({ ...props }: Record<string, unknown>) => (
|
||||||
<Tag className={classes} {...props} />
|
<Tag className={classes} {...props} />
|
||||||
);
|
);
|
||||||
Component.displayName = Tag;
|
Component.displayName = Tag;
|
||||||
|
|
|
@ -62,7 +62,9 @@ export function MessageInput({
|
||||||
} = useAudioRecording({
|
} = useAudioRecording({
|
||||||
transcribeAudio,
|
transcribeAudio,
|
||||||
onTranscriptionComplete: text => {
|
onTranscriptionComplete: text => {
|
||||||
props.onChange?.({ target: { value: text } } as any);
|
props.onChange?.({
|
||||||
|
target: { value: text },
|
||||||
|
} as React.ChangeEvent<HTMLTextAreaElement>);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from "react";
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||||
import { Skeleton } from "@/components/ui/skeleton";
|
import { Skeleton } from "@/components/ui/skeleton";
|
||||||
|
|
||||||
export function DetailLoadingView({ title }: { title: string }) {
|
export function DetailLoadingView() {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Skeleton className="h-8 w-3/4 mb-6" /> {/* Title Skeleton */}
|
<Skeleton className="h-8 w-3/4 mb-6" /> {/* Title Skeleton */}
|
||||||
|
|
|
@ -52,7 +52,7 @@ export function ItemRenderer({
|
||||||
// Fallback to generic item for unknown types
|
// Fallback to generic item for unknown types
|
||||||
return (
|
return (
|
||||||
<GenericItemComponent
|
<GenericItemComponent
|
||||||
item={item as any}
|
item={item as Record<string, unknown>}
|
||||||
index={index}
|
index={index}
|
||||||
keyPrefix={keyPrefix}
|
keyPrefix={keyPrefix}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -616,7 +616,7 @@ describe("ResponseDetailView", () => {
|
||||||
type: "unknown_type",
|
type: "unknown_type",
|
||||||
custom_field: "custom_value",
|
custom_field: "custom_value",
|
||||||
data: { nested: "object" },
|
data: { nested: "object" },
|
||||||
} as any,
|
} as unknown,
|
||||||
],
|
],
|
||||||
input: [],
|
input: [],
|
||||||
};
|
};
|
||||||
|
@ -666,7 +666,7 @@ describe("ResponseDetailView", () => {
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
call_id: "call_123",
|
call_id: "call_123",
|
||||||
content: "sunny and warm",
|
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: [],
|
input: [],
|
||||||
};
|
};
|
||||||
|
@ -706,7 +706,7 @@ describe("ResponseDetailView", () => {
|
||||||
status: "completed",
|
status: "completed",
|
||||||
call_id: "call_123",
|
call_id: "call_123",
|
||||||
output: "sunny and warm",
|
output: "sunny and warm",
|
||||||
} as any, // Using any to bypass the type restriction for this test
|
} as unknown,
|
||||||
],
|
],
|
||||||
input: [],
|
input: [],
|
||||||
};
|
};
|
||||||
|
|
|
@ -565,7 +565,7 @@ describe("ResponsesTable", () => {
|
||||||
id: "unknown_123",
|
id: "unknown_123",
|
||||||
status: "completed",
|
status: "completed",
|
||||||
custom_field: "custom_value",
|
custom_field: "custom_value",
|
||||||
} as any,
|
} as unknown,
|
||||||
],
|
],
|
||||||
input: [{ type: "message", content: "input" }],
|
input: [{ type: "message", content: "input" }],
|
||||||
};
|
};
|
||||||
|
@ -594,7 +594,7 @@ describe("ResponsesTable", () => {
|
||||||
{
|
{
|
||||||
type: "unknown_type",
|
type: "unknown_type",
|
||||||
data: "some data",
|
data: "some data",
|
||||||
} as any,
|
} as unknown,
|
||||||
],
|
],
|
||||||
input: [{ type: "message", content: "input" }],
|
input: [{ type: "message", content: "input" }],
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,7 +56,9 @@ function getInputText(response: OpenAIResponse): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function getOutputText(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<string, unknown>)
|
||||||
|
);
|
||||||
if (firstMessage) {
|
if (firstMessage) {
|
||||||
const content = extractContentFromItem(firstMessage as MessageItem);
|
const content = extractContentFromItem(firstMessage as MessageItem);
|
||||||
if (content) {
|
if (content) {
|
||||||
|
@ -65,14 +67,14 @@ function getOutputText(response: OpenAIResponse): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
const functionCall = response.output.find(item =>
|
const functionCall = response.output.find(item =>
|
||||||
isFunctionCallItem(item as any)
|
isFunctionCallItem(item as Record<string, unknown>)
|
||||||
);
|
);
|
||||||
if (functionCall) {
|
if (functionCall) {
|
||||||
return formatFunctionCall(functionCall as FunctionCallItem);
|
return formatFunctionCall(functionCall as FunctionCallItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
const webSearchCall = response.output.find(item =>
|
const webSearchCall = response.output.find(item =>
|
||||||
isWebSearchCallItem(item as any)
|
isWebSearchCallItem(item as Record<string, unknown>)
|
||||||
);
|
);
|
||||||
if (webSearchCall) {
|
if (webSearchCall) {
|
||||||
return formatWebSearchCall(webSearchCall as WebSearchCallItem);
|
return formatWebSearchCall(webSearchCall as WebSearchCallItem);
|
||||||
|
@ -136,7 +138,7 @@ export function ResponsesTable({ paginationOptions }: ResponsesTableProps) {
|
||||||
limit: params.limit,
|
limit: params.limit,
|
||||||
...(params.model && { model: params.model }),
|
...(params.model && { model: params.model }),
|
||||||
...(params.order && { order: params.order }),
|
...(params.order && { order: params.order }),
|
||||||
} as any);
|
} as Parameters<typeof client.responses.list>[0]);
|
||||||
|
|
||||||
const listResponse = response as ResponseListResponse;
|
const listResponse = response as ResponseListResponse;
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,6 @@ export function isFunctionCallOutputItem(
|
||||||
return (
|
return (
|
||||||
item.type === "function_call_output" &&
|
item.type === "function_call_output" &&
|
||||||
"call_id" in item &&
|
"call_id" in item &&
|
||||||
typeof (item as any).call_id === "string"
|
typeof (item as Record<string, unknown>).call_id === "string"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ export interface VectorStoreContentItem {
|
||||||
vector_store_id: string;
|
vector_store_id: string;
|
||||||
file_id: string;
|
file_id: string;
|
||||||
content: VectorStoreContent;
|
content: VectorStoreContent;
|
||||||
metadata: Record<string, any>;
|
metadata: Record<string, unknown>;
|
||||||
embedding?: number[];
|
embedding?: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,20 +54,11 @@ export class ContentsAPI {
|
||||||
return targetContent;
|
return targetContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateContent(
|
async updateContent(): Promise<VectorStoreContentItem> {
|
||||||
vectorStoreId: string,
|
|
||||||
fileId: string,
|
|
||||||
contentId: string,
|
|
||||||
updates: { content?: string; metadata?: Record<string, any> }
|
|
||||||
): Promise<VectorStoreContentItem> {
|
|
||||||
throw new Error("Individual content updates not yet implemented in API");
|
throw new Error("Individual content updates not yet implemented in API");
|
||||||
}
|
}
|
||||||
|
|
||||||
async deleteContent(
|
async deleteContent(): Promise<VectorStoreContentDeleteResponse> {
|
||||||
vectorStoreId: string,
|
|
||||||
fileId: string,
|
|
||||||
contentId: string
|
|
||||||
): Promise<VectorStoreContentDeleteResponse> {
|
|
||||||
throw new Error("Individual content deletion not yet implemented in API");
|
throw new Error("Individual content deletion not yet implemented in API");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +79,7 @@ export class ContentsAPI {
|
||||||
const contentItems: VectorStoreContentItem[] = [];
|
const contentItems: VectorStoreContentItem[] = [];
|
||||||
|
|
||||||
fileContents.content.forEach((content, contentIndex) => {
|
fileContents.content.forEach((content, contentIndex) => {
|
||||||
const rawContent = content as any;
|
const rawContent = content as Record<string, unknown>;
|
||||||
|
|
||||||
// Extract actual fields from the API response
|
// Extract actual fields from the API response
|
||||||
const embedding = rawContent.embedding || undefined;
|
const embedding = rawContent.embedding || undefined;
|
||||||
|
|
|
@ -53,7 +53,7 @@ describe("extractTextFromContentPart", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should handle arrays with plain strings", () => {
|
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.");
|
expect(extractTextFromContentPart(content)).toBe("This is a test.");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ describe("extractTextFromContentPart", () => {
|
||||||
null,
|
null,
|
||||||
undefined,
|
undefined,
|
||||||
{ type: "text", noTextProperty: true },
|
{ type: "text", noTextProperty: true },
|
||||||
] as any;
|
] as unknown;
|
||||||
expect(extractTextFromContentPart(content)).toBe("Valid");
|
expect(extractTextFromContentPart(content)).toBe("Valid");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ describe("extractTextFromContentPart", () => {
|
||||||
"Just a string.",
|
"Just a string.",
|
||||||
{ type: "image_url", image_url: { url: "http://example.com/image.png" } },
|
{ type: "image_url", image_url: { url: "http://example.com/image.png" } },
|
||||||
{ type: "text", text: "Last part." },
|
{ type: "text", text: "Last part." },
|
||||||
] as any;
|
] as unknown;
|
||||||
expect(extractTextFromContentPart(content)).toBe(
|
expect(extractTextFromContentPart(content)).toBe(
|
||||||
"First part. Just a string. [Image] Last part."
|
"First part. Just a string. [Image] Last part."
|
||||||
);
|
);
|
||||||
|
@ -83,7 +83,9 @@ describe("extractTextFromContentPart", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("extractDisplayableText (composite function)", () => {
|
describe("extractDisplayableText (composite function)", () => {
|
||||||
const mockFormatToolCallToString = (toolCall: any) => {
|
const mockFormatToolCallToString = (toolCall: {
|
||||||
|
function?: { name?: string; arguments?: unknown };
|
||||||
|
}) => {
|
||||||
if (!toolCall || !toolCall.function || !toolCall.function.name) return "";
|
if (!toolCall || !toolCall.function || !toolCall.function.name) return "";
|
||||||
const args = toolCall.function.arguments
|
const args = toolCall.function.arguments
|
||||||
? JSON.stringify(toolCall.function.arguments)
|
? JSON.stringify(toolCall.function.arguments)
|
||||||
|
|
|
@ -5,7 +5,9 @@
|
||||||
* with `name` and `arguments`.
|
* with `name` and `arguments`.
|
||||||
* @returns A formatted string or an empty string if data is malformed.
|
* @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 (
|
if (
|
||||||
!toolCall ||
|
!toolCall ||
|
||||||
!toolCall.function ||
|
!toolCall.function ||
|
||||||
|
@ -24,7 +26,7 @@ export function formatToolCallToString(toolCall: any): string {
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
argsString = JSON.stringify(args);
|
argsString = JSON.stringify(args);
|
||||||
} catch (error) {
|
} catch {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue