@kibadist/agentui-openai 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +78 -0
  2. package/package.json +4 -3
package/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # @kibadist/agentui-openai
2
+
3
+ OpenAI function-calling adapter for the AgentUI protocol. Works with any OpenAI-compatible API (OpenAI, DeepSeek, Ollama, vLLM, etc.).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @kibadist/agentui-openai
9
+ ```
10
+
11
+ **Peer dependency:** `openai` ^4.0.0
12
+
13
+ ## Quick start
14
+
15
+ ```ts
16
+ import OpenAI from "openai";
17
+ import { runAgentLoop } from "@kibadist/agentui-openai";
18
+
19
+ const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
20
+
21
+ await runAgentLoop({
22
+ openai,
23
+ model: "gpt-4o",
24
+ systemPrompt: "You are a helpful assistant. Use emit_ui_event to render UI.",
25
+ userMessage: "Show me a summary of recent sales",
26
+ allowedTypes: ["text-block", "info-card", "data-table"],
27
+ sessionId: "session-123",
28
+ onUIEvent: (event) => {
29
+ // Forward to SSE stream, save to DB, etc.
30
+ console.log(event);
31
+ },
32
+ });
33
+ ```
34
+
35
+ ## How it works
36
+
37
+ `runAgentLoop` creates an `emit_ui_event` function tool whose schema constrains the agent to only emit your registered component types. The agent calls this tool to append, replace, remove, toast, or navigate. The loop runs multi-turn until the model stops or `maxRounds` is reached.
38
+
39
+ ## Using different providers
40
+
41
+ ```ts
42
+ // OpenAI
43
+ new OpenAI({ apiKey: "sk-..." });
44
+
45
+ // DeepSeek
46
+ new OpenAI({ apiKey: "sk-...", baseURL: "https://api.deepseek.com" });
47
+
48
+ // Local (Ollama, vLLM)
49
+ new OpenAI({ apiKey: "none", baseURL: "http://localhost:11434/v1" });
50
+ ```
51
+
52
+ ## Options
53
+
54
+ | Option | Type | Default | Description |
55
+ |---|---|---|---|
56
+ | `openai` | `OpenAI` | required | OpenAI client instance |
57
+ | `model` | `string` | `"gpt-4o"` | Model name |
58
+ | `systemPrompt` | `string` | required | Agent instructions |
59
+ | `userMessage` | `string` | required | Current user message |
60
+ | `allowedTypes` | `string[]` | required | Component types the agent can emit |
61
+ | `sessionId` | `string` | required | Session ID injected into events |
62
+ | `onUIEvent` | `(event: UIEvent) => void` | required | Callback for each emitted UIEvent |
63
+ | `extraTools` | `ChatCompletionTool[]` | `[]` | Additional tools beyond the UI emitter |
64
+ | `onToolCall` | `(name, args) => string` | - | Handler for extra tool calls |
65
+ | `maxRounds` | `number` | `10` | Max tool-call rounds to prevent loops |
66
+
67
+ ## Exports
68
+
69
+ | Export | Kind | Description |
70
+ |---|---|---|
71
+ | `runAgentLoop` | function | Multi-turn agent loop with UI event emission |
72
+ | `createUIEmitterTool` | function | Generate the `emit_ui_event` tool definition |
73
+ | `UI_EMITTER_TOOL_NAME` | constant | `"emit_ui_event"` |
74
+ | `RunAgentLoopOptions` | interface | Options for `runAgentLoop` |
75
+
76
+ ## License
77
+
78
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kibadist/agentui-openai",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "AgentUI OpenAI integration",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,6 +8,7 @@
8
8
  "url": "https://github.com/kibadist/agentui.git",
9
9
  "directory": "packages/openai"
10
10
  },
11
+ "homepage": "https://github.com/kibadist/agentui#readme",
11
12
  "publishConfig": {
12
13
  "access": "public"
13
14
  },
@@ -24,8 +25,8 @@
24
25
  "dist"
25
26
  ],
26
27
  "dependencies": {
27
- "@kibadist/agentui-protocol": "0.1.0",
28
- "@kibadist/agentui-validate": "0.1.0"
28
+ "@kibadist/agentui-protocol": "0.1.2",
29
+ "@kibadist/agentui-validate": "0.1.2"
29
30
  },
30
31
  "peerDependencies": {
31
32
  "openai": "^4.0.0"