aidk
v0.1.8
Published
JSX framework for building AI applications
Maintainers
Readme
aidk
Core framework for building AI agents with JSX.
Installation
pnpm add aidkUsage
import {
EngineComponent,
ContextObjectModel,
TickState,
Section,
Message,
Timeline,
createEngine,
createTool
} from 'aidk';
import { z } from 'zod';
// Define a tool
const greetTool = createTool({
name: 'greet',
description: 'Greet someone',
input: z.object({ name: z.string() }),
execute: async ({ name }) => ({ greeting: `Hello, ${name}!` }),
});
// Define an agent
class MyAgent extends Component {
render(com: COM, state: TickState) {
return (
<>
<Timeline>
{state.current?.timeline?.map((entry, i) => (
<Message key={i} role={entry.message?.role} content={entry.message?.content} />
))}
</Timeline>
<Section id="instructions" audience="model">
You are a helpful assistant.
</Section>
<Tool definition={greetTool} />
</>
);
}
}
// Execute
const engine = createEngine();
const result = await engine.execute(
{ timeline: [{ kind: 'message', message: { role: 'user', content: [{ type: 'text', text: 'Hi' }] } }] },
<MyAgent />
);Key Exports
createEngine()- Create an execution engineEngineComponent- Base class for agent componentscreateTool()- Create a typed tool definitionSection- Content section componentMessage- Message componentTimeline- Conversation history componentContext- Execution context access
Documentation
See the full documentation.
