- Context Compaction System with token counting and summarization - Deterministic State Machine for flow control (no LLM decisions) - Parallel Execution Engine (up to 12 concurrent sessions) - Event-Driven Coordination via Event Bus - Agent Workspace Isolation (tools, memory, identity, files) - YAML Workflow Integration (OpenClaw/Lobster compatible) - Claude Code integration layer - Complete demo UI with real-time visualization - Comprehensive documentation and README Components: - agent-system/: Context management, token counting, subagent spawning - pipeline-system/: State machine, parallel executor, event bus, workflows - skills/: AI capabilities (LLM, ASR, TTS, VLM, image generation, etc.) - src/app/: Next.js demo application Total: ~100KB of production-ready TypeScript code
58 lines
1.4 KiB
TypeScript
Executable File
58 lines
1.4 KiB
TypeScript
Executable File
import ZAI, { VisionMessage } from 'z-ai-web-dev-sdk';
|
|
|
|
async function main(imageUrl: string, prompt: string) {
|
|
try {
|
|
const zai = await ZAI.create();
|
|
|
|
const messages: VisionMessage[] = [
|
|
{
|
|
role: 'assistant',
|
|
content: [
|
|
{ type: 'text', text: 'Output only text, no markdown.' }
|
|
]
|
|
},
|
|
{
|
|
role: 'user',
|
|
content: [
|
|
{ type: 'text', text: prompt },
|
|
{ type: 'image_url', image_url: { url: imageUrl } }
|
|
]
|
|
}
|
|
];
|
|
|
|
// const messages: VisionMessage[] = [
|
|
// {
|
|
// role: 'user',
|
|
// content: [
|
|
// { type: 'text', text: prompt },
|
|
// { type: 'video_url', video_url: { url: imageUrl } }
|
|
// ]
|
|
// }
|
|
// ];
|
|
|
|
// const messages: VisionMessage[] = [
|
|
// {
|
|
// role: 'user',
|
|
// content: [
|
|
// { type: 'text', text: prompt },
|
|
// { type: 'file_url', file_url: { url: imageUrl } }
|
|
// ]
|
|
// }
|
|
// ];
|
|
|
|
const response = await zai.chat.completions.createVision({
|
|
model: 'glm-4.6v',
|
|
messages,
|
|
thinking: { type: 'disabled' }
|
|
});
|
|
|
|
const reply = response.choices?.[0]?.message?.content;
|
|
console.log('Vision model reply:');
|
|
console.log(reply ?? JSON.stringify(response, null, 2));
|
|
} catch (err: any) {
|
|
console.error('Vision chat failed:', err?.message || err);
|
|
}
|
|
}
|
|
|
|
main("https://cdn.bigmodel.cn/static/logo/register.png", "Please describe this image.");
|