Download src/shared/types.ts from noodcon/PI: direct link, hf CLI and curl.
- Browser
- Download file 2.18 kB
-
https://huggingface.co/spaces/noodcon/PI/resolve/main/src/shared/types.ts
- Command line
-
hf download hf://spaces/noodcon/PI/src/shared/types.ts
-
curl -L -o types.ts https://huggingface.co/spaces/noodcon/PI/resolve/main/src/shared/types.ts
2.18 kB
| // Kiểu dữ liệu dùng chung giữa main thread và worker. | |
| export interface TextContent { | |
| type: 'text'; | |
| text: string; | |
| } | |
| export interface ThinkingContent { | |
| type: 'thinking'; | |
| thinking: string; | |
| } | |
| export interface ToolCall { | |
| type: 'toolCall'; | |
| id: string; | |
| name: string; | |
| arguments: Record<string, unknown>; | |
| } | |
| export type AssistantContent = TextContent | ThinkingContent | ToolCall; | |
| export interface Usage { | |
| input: number; | |
| output: number; | |
| totalTokens: number; | |
| } | |
| export interface UserMessage { | |
| role: 'user'; | |
| content: string; | |
| timestamp: number; | |
| } | |
| export type StopReason = 'stop' | 'length' | 'toolUse' | 'error' | 'aborted'; | |
| export interface AssistantMessage { | |
| role: 'assistant'; | |
| content: AssistantContent[]; | |
| stopReason?: StopReason; | |
| errorMessage?: string; | |
| usage: Usage; | |
| timestamp: number; | |
| } | |
| export interface ToolResultMessage { | |
| role: 'toolResult'; | |
| toolCallId: string; | |
| toolName: string; | |
| content: TextContent[]; | |
| details: { exitCode?: number; path?: string }; | |
| isError: boolean; | |
| timestamp: number; | |
| } | |
| export type AgentMessage = UserMessage | AssistantMessage | ToolResultMessage; | |
| /** Schema JSON của tham số tool (đủ dùng cho chat template của MiniCPM). */ | |
| export interface ToolSchema { | |
| type: 'object'; | |
| properties: Record<string, { type: 'string' | 'number' | 'boolean' | 'object' | 'array'; description?: string }>; | |
| required: string[]; | |
| } | |
| export interface ToolDef { | |
| name: string; | |
| label: string; | |
| description: string; | |
| parameters: ToolSchema; | |
| } | |
| /** Cặp [đường dẫn, mục] để lưu/khôi phục toàn bộ workspace (file, thư mục, symlink). */ | |
| export type SerializedEntry = | |
| | { type: 'file'; base64: string; mode: number } | |
| | { type: 'directory'; mode: number } | |
| | { type: 'symlink'; target: string }; | |
| export interface WorkspaceState { | |
| version: 1; | |
| files: Record<string, string>; | |
| entries: Array<[string, SerializedEntry]>; | |
| messages: AgentMessage[]; | |
| } | |
| export interface DeviceInfo { | |
| vendor?: string; | |
| architecture?: string; | |
| maxStorageBufferBindingSize?: number; | |
| features?: string[]; | |
| } | |
| export interface ShellResult { | |
| stdout: string; | |
| stderr: string; | |
| exitCode: number; | |
| } | |