@vibe-agent-toolkit/runtime-openai 0.1.2-rc.3
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.
- package/README.md +268 -0
- package/dist/adapters/common-helpers.d.ts +30 -0
- package/dist/adapters/common-helpers.d.ts.map +1 -0
- package/dist/adapters/common-helpers.js +63 -0
- package/dist/adapters/common-helpers.js.map +1 -0
- package/dist/adapters/conversational-assistant.d.ts +54 -0
- package/dist/adapters/conversational-assistant.d.ts.map +1 -0
- package/dist/adapters/conversational-assistant.js +81 -0
- package/dist/adapters/conversational-assistant.js.map +1 -0
- package/dist/adapters/llm-analyzer.d.ts +81 -0
- package/dist/adapters/llm-analyzer.d.ts.map +1 -0
- package/dist/adapters/llm-analyzer.js +100 -0
- package/dist/adapters/llm-analyzer.js.map +1 -0
- package/dist/adapters/pure-function.d.ts +91 -0
- package/dist/adapters/pure-function.d.ts.map +1 -0
- package/dist/adapters/pure-function.js +113 -0
- package/dist/adapters/pure-function.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +29 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# @vibe-agent-toolkit/runtime-openai
|
|
2
|
+
|
|
3
|
+
OpenAI SDK runtime adapter for VAT (Vibe Agent Toolkit) agents.
|
|
4
|
+
|
|
5
|
+
Converts VAT archetype agents to OpenAI SDK primitives (function calling, chat completions), enabling direct API access without framework overhead while maintaining type safety and agent semantics.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @vibe-agent-toolkit/runtime-openai openai
|
|
11
|
+
# or
|
|
12
|
+
bun add @vibe-agent-toolkit/runtime-openai openai
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Supported Archetypes
|
|
16
|
+
|
|
17
|
+
### Pure Function Tools → Function Calling
|
|
18
|
+
|
|
19
|
+
Converts synchronous, deterministic VAT agents to OpenAI function calling tools.
|
|
20
|
+
|
|
21
|
+
**Use cases:** Validation, transformation, computation, structured data operations.
|
|
22
|
+
|
|
23
|
+
#### Example: Haiku Validator
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import OpenAI from 'openai';
|
|
27
|
+
import { haikuValidatorAgent, HaikuSchema, HaikuValidationResultSchema } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
28
|
+
import { convertPureFunctionToTool } from '@vibe-agent-toolkit/runtime-openai';
|
|
29
|
+
|
|
30
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
31
|
+
|
|
32
|
+
// Convert VAT agent to OpenAI tool
|
|
33
|
+
const { tool, execute } = convertPureFunctionToTool(
|
|
34
|
+
haikuValidatorAgent,
|
|
35
|
+
HaikuSchema,
|
|
36
|
+
HaikuValidationResultSchema
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Use with OpenAI function calling
|
|
40
|
+
const response = await openai.chat.completions.create({
|
|
41
|
+
model: 'gpt-4o-mini',
|
|
42
|
+
messages: [
|
|
43
|
+
{ role: 'user', content: 'Write a haiku about an orange cat and validate it' }
|
|
44
|
+
],
|
|
45
|
+
tools: [tool],
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Execute tool calls
|
|
49
|
+
for (const toolCall of response.choices[0].message.tool_calls ?? []) {
|
|
50
|
+
if (toolCall.function.name === tool.function.name) {
|
|
51
|
+
const args = JSON.parse(toolCall.function.arguments);
|
|
52
|
+
const result = await execute(args);
|
|
53
|
+
console.log(result); // { valid: true, syllables: { line1: 5, line2: 7, line3: 5 } }
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### LLM Analyzer → Chat Completions
|
|
59
|
+
|
|
60
|
+
Converts LLM-powered VAT agents to executable async functions using OpenAI chat completions API.
|
|
61
|
+
|
|
62
|
+
**Use cases:** Content generation, analysis, transformation, structured output from LLMs.
|
|
63
|
+
|
|
64
|
+
### Conversational Assistant → Multi-Turn Chat
|
|
65
|
+
|
|
66
|
+
Converts conversational assistant agents to stateful chat functions with conversation history management.
|
|
67
|
+
|
|
68
|
+
**Use cases:** Interactive assistants, multi-turn dialogues, context-aware conversations, customer support bots.
|
|
69
|
+
|
|
70
|
+
#### Example: Name Generator
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
import OpenAI from 'openai';
|
|
74
|
+
import { nameGeneratorAgent, NameGeneratorInputSchema, NameSuggestionSchema } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
75
|
+
import { convertLLMAnalyzerToFunction } from '@vibe-agent-toolkit/runtime-openai';
|
|
76
|
+
|
|
77
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
78
|
+
|
|
79
|
+
// Convert VAT agent to executable function
|
|
80
|
+
const generateName = convertLLMAnalyzerToFunction(
|
|
81
|
+
nameGeneratorAgent,
|
|
82
|
+
NameGeneratorInputSchema,
|
|
83
|
+
NameSuggestionSchema,
|
|
84
|
+
{
|
|
85
|
+
client: openai,
|
|
86
|
+
model: 'gpt-4o-mini',
|
|
87
|
+
temperature: 0.9,
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// Execute directly
|
|
92
|
+
const result = await generateName({
|
|
93
|
+
characteristics: {
|
|
94
|
+
physical: { furColor: 'Orange' },
|
|
95
|
+
behavioral: { personality: ['Distinguished'] },
|
|
96
|
+
description: 'A noble orange cat',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log(result.name); // "Sir Whiskersworth III"
|
|
101
|
+
console.log(result.reasoning); // "This name captures..."
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
#### Example: Breed Advisor (Multi-Turn)
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
import OpenAI from 'openai';
|
|
108
|
+
import { breedAdvisorAgent, BreedAdvisorInputSchema, BreedAdvisorOutputSchema } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
109
|
+
import { convertConversationalAssistantToFunction, type ConversationalSessionState } from '@vibe-agent-toolkit/runtime-openai';
|
|
110
|
+
|
|
111
|
+
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
112
|
+
|
|
113
|
+
// Convert VAT agent to executable function
|
|
114
|
+
const chat = convertConversationalAssistantToFunction(
|
|
115
|
+
breedAdvisorAgent,
|
|
116
|
+
BreedAdvisorInputSchema,
|
|
117
|
+
BreedAdvisorOutputSchema,
|
|
118
|
+
{
|
|
119
|
+
client: openai,
|
|
120
|
+
model: 'gpt-4o',
|
|
121
|
+
temperature: 0.8,
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Initialize session state (persists across turns)
|
|
126
|
+
const session: ConversationalSessionState = { history: [] };
|
|
127
|
+
let profile = { conversationPhase: 'gathering' };
|
|
128
|
+
|
|
129
|
+
// Turn 1
|
|
130
|
+
const result1 = await chat(
|
|
131
|
+
{ message: 'I need help finding a cat breed', sessionState: { profile } },
|
|
132
|
+
session
|
|
133
|
+
);
|
|
134
|
+
console.log(result1.reply); // "I'd love to help! ..."
|
|
135
|
+
profile = result1.updatedProfile;
|
|
136
|
+
|
|
137
|
+
// Turn 2 (uses accumulated history)
|
|
138
|
+
const result2 = await chat(
|
|
139
|
+
{ message: 'I live in an apartment and love classical music', sessionState: { profile } },
|
|
140
|
+
session
|
|
141
|
+
);
|
|
142
|
+
console.log(result2.reply); // "Classical music! That's wonderful..."
|
|
143
|
+
profile = result2.updatedProfile;
|
|
144
|
+
|
|
145
|
+
// Turn 3 (recommendations appear when ready)
|
|
146
|
+
const result3 = await chat(
|
|
147
|
+
{ message: "I prefer calm cats and don't mind grooming", sessionState: { profile } },
|
|
148
|
+
session
|
|
149
|
+
);
|
|
150
|
+
console.log(result3.recommendations); // [{ breed: 'Persian', matchScore: 95, ... }]
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Why Direct OpenAI SDK?
|
|
154
|
+
|
|
155
|
+
Unlike framework-based adapters (Vercel AI SDK, LangChain), this adapter provides:
|
|
156
|
+
|
|
157
|
+
- **Zero framework overhead** - Direct API access, minimal abstraction
|
|
158
|
+
- **Lightweight** - Only OpenAI SDK dependency
|
|
159
|
+
- **Full API control** - Access to all OpenAI-specific features
|
|
160
|
+
- **Simpler debugging** - Fewer layers between your code and the API
|
|
161
|
+
|
|
162
|
+
Perfect for:
|
|
163
|
+
- Production applications requiring minimal dependencies
|
|
164
|
+
- Users already familiar with OpenAI SDK
|
|
165
|
+
- Projects needing fine-grained control over API calls
|
|
166
|
+
- Serverless/edge environments with size constraints
|
|
167
|
+
|
|
168
|
+
## API Reference
|
|
169
|
+
|
|
170
|
+
### `convertPureFunctionToTool()`
|
|
171
|
+
|
|
172
|
+
Converts a VAT Pure Function agent to an OpenAI function calling tool definition.
|
|
173
|
+
|
|
174
|
+
**Parameters:**
|
|
175
|
+
- `agent: PureFunctionAgent<TInput, TOutput>` - The VAT agent to convert
|
|
176
|
+
- `inputSchema: z.ZodType<TInput>` - Zod schema for input validation
|
|
177
|
+
- `outputSchema: z.ZodType<TOutput>` - Zod schema for output validation
|
|
178
|
+
|
|
179
|
+
**Returns:** Object with:
|
|
180
|
+
- `tool: OpenAI.Chat.ChatCompletionTool` - OpenAI tool definition
|
|
181
|
+
- `execute: (args: TInput) => Promise<TOutput>` - Function to execute tool calls
|
|
182
|
+
- `metadata: { name, description, version, archetype }` - Agent metadata
|
|
183
|
+
- `inputSchema: z.ZodType<TInput>` - Original input schema
|
|
184
|
+
- `outputSchema: z.ZodType<TOutput>` - Original output schema
|
|
185
|
+
|
|
186
|
+
### `convertPureFunctionsToTools()`
|
|
187
|
+
|
|
188
|
+
Batch converts multiple pure function agents to OpenAI tools.
|
|
189
|
+
|
|
190
|
+
**Parameters:**
|
|
191
|
+
- `configs: Record<string, ToolConversionConfig>` - Map of tool names to conversion configs
|
|
192
|
+
|
|
193
|
+
**Returns:** `Record<string, { tool, execute, metadata }>` - Map of converted tools
|
|
194
|
+
|
|
195
|
+
### `convertLLMAnalyzerToFunction()`
|
|
196
|
+
|
|
197
|
+
Converts a VAT LLM Analyzer agent to an executable async function.
|
|
198
|
+
|
|
199
|
+
**Parameters:**
|
|
200
|
+
- `agent: Agent<TInput, TOutput>` - The VAT agent to convert
|
|
201
|
+
- `inputSchema: z.ZodType<TInput>` - Zod schema for input validation
|
|
202
|
+
- `outputSchema: z.ZodType<TOutput>` - Zod schema for output validation
|
|
203
|
+
- `openaiConfig: OpenAIConfig` - OpenAI configuration
|
|
204
|
+
|
|
205
|
+
**Returns:** `(input: TInput) => Promise<TOutput>` - Executable async function
|
|
206
|
+
|
|
207
|
+
### `convertLLMAnalyzersToFunctions()`
|
|
208
|
+
|
|
209
|
+
Batch converts multiple LLM Analyzer agents with shared OpenAI config.
|
|
210
|
+
|
|
211
|
+
**Parameters:**
|
|
212
|
+
- `configs: Record<string, LLMAnalyzerConversionConfig>` - Map of function names to conversion configs
|
|
213
|
+
- `openaiConfig: OpenAIConfig` - Shared OpenAI configuration
|
|
214
|
+
|
|
215
|
+
**Returns:** `Record<string, (input: any) => Promise<any>>` - Map of executable functions
|
|
216
|
+
|
|
217
|
+
### `convertConversationalAssistantToFunction()`
|
|
218
|
+
|
|
219
|
+
Converts a VAT Conversational Assistant agent to an executable async function with session state management.
|
|
220
|
+
|
|
221
|
+
**Parameters:**
|
|
222
|
+
- `agent: Agent<TInput, TOutput>` - The VAT conversational assistant agent to convert
|
|
223
|
+
- `inputSchema: z.ZodType<TInput>` - Zod schema for input validation
|
|
224
|
+
- `outputSchema: z.ZodType<TOutput>` - Zod schema for output validation
|
|
225
|
+
- `openaiConfig: OpenAIConfig` - OpenAI configuration
|
|
226
|
+
- `systemPrompt?: string` - Optional system prompt (overrides agent's system prompt)
|
|
227
|
+
|
|
228
|
+
**Returns:** `(input: TInput, session: ConversationalSessionState) => Promise<TOutput>` - Executable async function with session state
|
|
229
|
+
|
|
230
|
+
**Session State:**
|
|
231
|
+
```typescript
|
|
232
|
+
interface ConversationalSessionState {
|
|
233
|
+
history: Message[]; // Conversation history
|
|
234
|
+
state?: Record<string, unknown>; // Custom state data
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Type Definitions
|
|
239
|
+
|
|
240
|
+
### `OpenAIConfig`
|
|
241
|
+
|
|
242
|
+
```typescript
|
|
243
|
+
interface OpenAIConfig {
|
|
244
|
+
client: OpenAI; // OpenAI client instance
|
|
245
|
+
model: string; // Model to use (e.g., 'gpt-4o-mini')
|
|
246
|
+
temperature?: number; // 0-2, default 0.7
|
|
247
|
+
maxTokens?: number; // Maximum tokens to generate
|
|
248
|
+
additionalSettings?: Omit<...>; // Other chat completion params
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Examples
|
|
253
|
+
|
|
254
|
+
See [@vibe-agent-toolkit/vat-example-cat-agents](../vat-example-cat-agents) for complete agent examples that work with this adapter.
|
|
255
|
+
|
|
256
|
+
## Comparison with Other Adapters
|
|
257
|
+
|
|
258
|
+
| Feature | runtime-openai | runtime-vercel-ai-sdk | runtime-langchain |
|
|
259
|
+
|---------|----------------|----------------------|-------------------|
|
|
260
|
+
| **Dependencies** | 1 (openai) | 2 (ai, @ai-sdk/*) | 2 (langchain, @langchain/core) |
|
|
261
|
+
| **Bundle Size** | Smallest | Medium | Largest |
|
|
262
|
+
| **API Control** | Full | High | High |
|
|
263
|
+
| **Learning Curve** | Low (if you know OpenAI SDK) | Medium | High |
|
|
264
|
+
| **Best For** | Direct API access, minimal deps | Multi-provider, streaming | Agent frameworks, RAG |
|
|
265
|
+
|
|
266
|
+
## License
|
|
267
|
+
|
|
268
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common helper functions for OpenAI runtime adapters
|
|
3
|
+
*/
|
|
4
|
+
import type { Message } from '@vibe-agent-toolkit/agent-runtime';
|
|
5
|
+
import type { OpenAIConfig } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Helper to extract text from OpenAI API response
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractTextFromResponse(response: {
|
|
10
|
+
choices: Array<{
|
|
11
|
+
message: {
|
|
12
|
+
content: string | null;
|
|
13
|
+
};
|
|
14
|
+
}>;
|
|
15
|
+
}): string;
|
|
16
|
+
/**
|
|
17
|
+
* Creates a callLLM function for LLM Analyzer agents
|
|
18
|
+
*
|
|
19
|
+
* @param openaiConfig - OpenAI configuration
|
|
20
|
+
* @returns callLLM function for single-turn prompts
|
|
21
|
+
*/
|
|
22
|
+
export declare function createLLMAnalyzerCallLLM(openaiConfig: OpenAIConfig): (prompt: string) => Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a callLLM function for Conversational Assistant agents
|
|
25
|
+
*
|
|
26
|
+
* @param openaiConfig - OpenAI configuration
|
|
27
|
+
* @returns callLLM function for multi-turn conversations
|
|
28
|
+
*/
|
|
29
|
+
export declare function createConversationalCallLLM(openaiConfig: OpenAIConfig): (messages: Message[]) => Promise<string>;
|
|
30
|
+
//# sourceMappingURL=common-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-helpers.d.ts","sourceRoot":"","sources":["../../src/adapters/common-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE;IAAE,OAAO,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE;YAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAErH;AA+BD;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,YAAY,IACnD,QAAQ,MAAM,KAAG,OAAO,CAAC,MAAM,CAAC,CAe/C;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAAE,YAAY,IACtD,UAAU,OAAO,EAAE,KAAG,OAAO,CAAC,MAAM,CAAC,CAqBpD"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common helper functions for OpenAI runtime adapters
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Helper to extract text from OpenAI API response
|
|
6
|
+
*/
|
|
7
|
+
export function extractTextFromResponse(response) {
|
|
8
|
+
return response.choices[0]?.message.content ?? '';
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Helper to create OpenAI API parameters with optional fields
|
|
12
|
+
*/
|
|
13
|
+
function createBaseParams(model, temperature, maxTokens) {
|
|
14
|
+
const params = { model };
|
|
15
|
+
// Only add optional parameters if defined
|
|
16
|
+
if (temperature !== undefined) {
|
|
17
|
+
params.temperature = temperature;
|
|
18
|
+
}
|
|
19
|
+
if (maxTokens !== undefined) {
|
|
20
|
+
params.max_tokens = maxTokens;
|
|
21
|
+
}
|
|
22
|
+
return params;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates a callLLM function for LLM Analyzer agents
|
|
26
|
+
*
|
|
27
|
+
* @param openaiConfig - OpenAI configuration
|
|
28
|
+
* @returns callLLM function for single-turn prompts
|
|
29
|
+
*/
|
|
30
|
+
export function createLLMAnalyzerCallLLM(openaiConfig) {
|
|
31
|
+
return async (prompt) => {
|
|
32
|
+
const params = createBaseParams(openaiConfig.model, openaiConfig.temperature, openaiConfig.maxTokens);
|
|
33
|
+
const response = await openaiConfig.client.chat.completions.create({
|
|
34
|
+
...params,
|
|
35
|
+
messages: [{ role: 'user', content: prompt }],
|
|
36
|
+
...openaiConfig.additionalSettings,
|
|
37
|
+
});
|
|
38
|
+
return extractTextFromResponse(response);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Creates a callLLM function for Conversational Assistant agents
|
|
43
|
+
*
|
|
44
|
+
* @param openaiConfig - OpenAI configuration
|
|
45
|
+
* @returns callLLM function for multi-turn conversations
|
|
46
|
+
*/
|
|
47
|
+
export function createConversationalCallLLM(openaiConfig) {
|
|
48
|
+
return async (messages) => {
|
|
49
|
+
const params = createBaseParams(openaiConfig.model, openaiConfig.temperature, openaiConfig.maxTokens);
|
|
50
|
+
// Convert VAT messages to OpenAI format
|
|
51
|
+
const openaiMessages = messages.map((m) => ({
|
|
52
|
+
role: m.role,
|
|
53
|
+
content: m.content,
|
|
54
|
+
}));
|
|
55
|
+
const response = await openaiConfig.client.chat.completions.create({
|
|
56
|
+
...params,
|
|
57
|
+
messages: openaiMessages,
|
|
58
|
+
...openaiConfig.additionalSettings,
|
|
59
|
+
});
|
|
60
|
+
return extractTextFromResponse(response);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=common-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-helpers.js","sourceRoot":"","sources":["../../src/adapters/common-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,UAAU,uBAAuB,CAAC,QAAqE;IAC3G,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;AACpD,CAAC;AAED;;GAEG;AACH,SAAS,gBAAgB,CACvB,KAAa,EACb,WAAoB,EACpB,SAAkB;IAMlB,MAAM,MAAM,GAIR,EAAE,KAAK,EAAE,CAAC;IAEd,0CAA0C;IAC1C,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;IACD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,MAAM,CAAC,UAAU,GAAG,SAAS,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,YAA0B;IACjE,OAAO,KAAK,EAAE,MAAc,EAAmB,EAAE;QAC/C,MAAM,MAAM,GAAG,gBAAgB,CAC7B,YAAY,CAAC,KAAK,EAClB,YAAY,CAAC,WAAW,EACxB,YAAY,CAAC,SAAS,CACvB,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACjE,GAAG,MAAM;YACT,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;YAC7C,GAAG,YAAY,CAAC,kBAAkB;SACnC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CAAC,YAA0B;IACpE,OAAO,KAAK,EAAE,QAAmB,EAAmB,EAAE;QACpD,MAAM,MAAM,GAAG,gBAAgB,CAC7B,YAAY,CAAC,KAAK,EAClB,YAAY,CAAC,WAAW,EACxB,YAAY,CAAC,SAAS,CACvB,CAAC;QAEF,wCAAwC;QACxC,MAAM,cAAc,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,EAAE,CAAC,CAAC,IAAuC;YAC/C,OAAO,EAAE,CAAC,CAAC,OAAO;SACnB,CAAC,CAAC,CAAC;QAEJ,MAAM,QAAQ,GAAG,MAAM,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACjE,GAAG,MAAM;YACT,QAAQ,EAAE,cAAc;YACxB,GAAG,YAAY,CAAC,kBAAkB;SACnC,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Agent, Message } from '@vibe-agent-toolkit/agent-runtime';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { OpenAIConfig } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Session state type for conversational assistants
|
|
6
|
+
* Includes conversation history and custom state data
|
|
7
|
+
*/
|
|
8
|
+
export interface ConversationalSessionState {
|
|
9
|
+
/** Conversation history */
|
|
10
|
+
history: Message[];
|
|
11
|
+
/** Custom state data (e.g., user profile, context) */
|
|
12
|
+
state?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Converts a VAT Conversational Assistant agent to an executable async function with OpenAI
|
|
16
|
+
*
|
|
17
|
+
* @param agent - The VAT conversational assistant agent to convert
|
|
18
|
+
* @param inputSchema - Zod schema for validating inputs
|
|
19
|
+
* @param outputSchema - Zod schema for validating outputs
|
|
20
|
+
* @param openaiConfig - OpenAI configuration
|
|
21
|
+
* @param systemPrompt - Optional system prompt to prepend to conversation
|
|
22
|
+
* @returns Async function that executes the agent with OpenAI chat completions
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import OpenAI from 'openai';
|
|
27
|
+
* import { breedAdvisorAgent, BreedAdvisorInputSchema, BreedAdvisorOutputSchema } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
28
|
+
* import { convertConversationalAssistantToFunction } from '@vibe-agent-toolkit/runtime-openai';
|
|
29
|
+
*
|
|
30
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
31
|
+
*
|
|
32
|
+
* const chat = convertConversationalAssistantToFunction(
|
|
33
|
+
* breedAdvisorAgent,
|
|
34
|
+
* BreedAdvisorInputSchema,
|
|
35
|
+
* BreedAdvisorOutputSchema,
|
|
36
|
+
* {
|
|
37
|
+
* client: openai,
|
|
38
|
+
* model: 'gpt-4o',
|
|
39
|
+
* temperature: 0.8,
|
|
40
|
+
* }
|
|
41
|
+
* );
|
|
42
|
+
*
|
|
43
|
+
* // First turn
|
|
44
|
+
* let session: ConversationalSessionState = { history: [] };
|
|
45
|
+
* const result1 = await chat({ message: 'I need help finding a cat', sessionState: { profile: {} } }, session);
|
|
46
|
+
* console.log(result1.reply);
|
|
47
|
+
*
|
|
48
|
+
* // Second turn (uses accumulated history)
|
|
49
|
+
* const result2 = await chat({ message: 'I live in an apartment', sessionState: { profile: result1.updatedProfile } }, session);
|
|
50
|
+
* console.log(result2.reply);
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function convertConversationalAssistantToFunction<TInput, TOutput>(agent: Agent<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>, openaiConfig: OpenAIConfig, systemPrompt?: string): (input: TInput, session: ConversationalSessionState) => Promise<TOutput>;
|
|
54
|
+
//# sourceMappingURL=conversational-assistant.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversational-assistant.d.ts","sourceRoot":"","sources":["../../src/adapters/conversational-assistant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAyB,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC/F,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD;;;GAGG;AACH,MAAM,WAAW,0BAA0B;IACzC,2BAA2B;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,wCAAwC,CAAC,MAAM,EAAE,OAAO,EACtE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAChC,YAAY,EAAE,YAAY,EAC1B,YAAY,CAAC,EAAE,MAAM,GACpB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,0BAA0B,KAAK,OAAO,CAAC,OAAO,CAAC,CAgD1E"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createConversationalCallLLM } from './common-helpers.js';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a VAT Conversational Assistant agent to an executable async function with OpenAI
|
|
4
|
+
*
|
|
5
|
+
* @param agent - The VAT conversational assistant agent to convert
|
|
6
|
+
* @param inputSchema - Zod schema for validating inputs
|
|
7
|
+
* @param outputSchema - Zod schema for validating outputs
|
|
8
|
+
* @param openaiConfig - OpenAI configuration
|
|
9
|
+
* @param systemPrompt - Optional system prompt to prepend to conversation
|
|
10
|
+
* @returns Async function that executes the agent with OpenAI chat completions
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import OpenAI from 'openai';
|
|
15
|
+
* import { breedAdvisorAgent, BreedAdvisorInputSchema, BreedAdvisorOutputSchema } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
16
|
+
* import { convertConversationalAssistantToFunction } from '@vibe-agent-toolkit/runtime-openai';
|
|
17
|
+
*
|
|
18
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
19
|
+
*
|
|
20
|
+
* const chat = convertConversationalAssistantToFunction(
|
|
21
|
+
* breedAdvisorAgent,
|
|
22
|
+
* BreedAdvisorInputSchema,
|
|
23
|
+
* BreedAdvisorOutputSchema,
|
|
24
|
+
* {
|
|
25
|
+
* client: openai,
|
|
26
|
+
* model: 'gpt-4o',
|
|
27
|
+
* temperature: 0.8,
|
|
28
|
+
* }
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* // First turn
|
|
32
|
+
* let session: ConversationalSessionState = { history: [] };
|
|
33
|
+
* const result1 = await chat({ message: 'I need help finding a cat', sessionState: { profile: {} } }, session);
|
|
34
|
+
* console.log(result1.reply);
|
|
35
|
+
*
|
|
36
|
+
* // Second turn (uses accumulated history)
|
|
37
|
+
* const result2 = await chat({ message: 'I live in an apartment', sessionState: { profile: result1.updatedProfile } }, session);
|
|
38
|
+
* console.log(result2.reply);
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function convertConversationalAssistantToFunction(agent, inputSchema, outputSchema, openaiConfig, systemPrompt) {
|
|
42
|
+
// Extract system prompt from agent manifest if not provided
|
|
43
|
+
const metadataSystemPrompt = agent.manifest.metadata?.['systemPrompt'];
|
|
44
|
+
const effectiveSystemPrompt = systemPrompt ??
|
|
45
|
+
(typeof metadataSystemPrompt === 'string'
|
|
46
|
+
? metadataSystemPrompt
|
|
47
|
+
: metadataSystemPrompt?.gathering);
|
|
48
|
+
// Create base callLLM function
|
|
49
|
+
const baseCallLLM = createConversationalCallLLM(openaiConfig);
|
|
50
|
+
// Wrap it to handle system prompt
|
|
51
|
+
const callLLM = async (messages) => {
|
|
52
|
+
// Prepend system prompt if provided
|
|
53
|
+
const messagesWithSystem = effectiveSystemPrompt
|
|
54
|
+
? [{ role: 'system', content: effectiveSystemPrompt }, ...messages]
|
|
55
|
+
: messages;
|
|
56
|
+
return baseCallLLM(messagesWithSystem);
|
|
57
|
+
};
|
|
58
|
+
// Return wrapped function
|
|
59
|
+
return async (input, session) => {
|
|
60
|
+
// Validate input
|
|
61
|
+
const validatedInput = inputSchema.parse(input);
|
|
62
|
+
// Initialize or use existing session history
|
|
63
|
+
if (!session.history) {
|
|
64
|
+
session.history = [];
|
|
65
|
+
}
|
|
66
|
+
// Create conversation context
|
|
67
|
+
const context = {
|
|
68
|
+
mockable: false,
|
|
69
|
+
history: session.history,
|
|
70
|
+
addToHistory: (role, content) => {
|
|
71
|
+
session.history.push({ role, content });
|
|
72
|
+
},
|
|
73
|
+
callLLM,
|
|
74
|
+
};
|
|
75
|
+
// Execute the agent
|
|
76
|
+
const output = await agent.execute(validatedInput, context);
|
|
77
|
+
// Validate output
|
|
78
|
+
return outputSchema.parse(output);
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=conversational-assistant.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversational-assistant.js","sourceRoot":"","sources":["../../src/adapters/conversational-assistant.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAalE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,wCAAwC,CACtD,KAA6B,EAC7B,WAA8B,EAC9B,YAAgC,EAChC,YAA0B,EAC1B,YAAqB;IAErB,4DAA4D;IAC5D,MAAM,oBAAoB,GAAG,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,cAAc,CAAC,CAAC;IACvE,MAAM,qBAAqB,GACzB,YAAY;QACZ,CAAC,OAAO,oBAAoB,KAAK,QAAQ;YACvC,CAAC,CAAC,oBAAoB;YACtB,CAAC,CAAE,oBAA+C,EAAE,SAAS,CAAC,CAAC;IAEnE,+BAA+B;IAC/B,MAAM,WAAW,GAAG,2BAA2B,CAAC,YAAY,CAAC,CAAC;IAE9D,kCAAkC;IAClC,MAAM,OAAO,GAAG,KAAK,EAAE,QAAmB,EAAmB,EAAE;QAC7D,oCAAoC;QACpC,MAAM,kBAAkB,GAAG,qBAAqB;YAC9C,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAiB,EAAE,OAAO,EAAE,qBAAqB,EAAE,EAAE,GAAG,QAAQ,CAAC;YAC5E,CAAC,CAAC,QAAQ,CAAC;QAEb,OAAO,WAAW,CAAC,kBAAkB,CAAC,CAAC;IACzC,CAAC,CAAC;IAEF,0BAA0B;IAC1B,OAAO,KAAK,EAAE,KAAa,EAAE,OAAmC,EAAoB,EAAE;QACpF,iBAAiB;QACjB,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEhD,6CAA6C;QAC7C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YACrB,OAAO,CAAC,OAAO,GAAG,EAAE,CAAC;QACvB,CAAC;QAED,8BAA8B;QAC9B,MAAM,OAAO,GAA0B;YACrC,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,YAAY,EAAE,CAAC,IAAqC,EAAE,OAAe,EAAE,EAAE;gBACvE,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;YAC1C,CAAC;YACD,OAAO;SACR,CAAC;QAEF,oBAAoB;QACpB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAE5D,kBAAkB;QAClB,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type Agent } from '@vibe-agent-toolkit/agent-runtime';
|
|
2
|
+
import type { z } from 'zod';
|
|
3
|
+
import type { LLMAnalyzerConversionConfigs, OpenAIConfig } from '../types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Converts a VAT LLM Analyzer agent to an executable async function with OpenAI
|
|
6
|
+
*
|
|
7
|
+
* @param agent - The VAT LLM analyzer agent to convert
|
|
8
|
+
* @param inputSchema - Zod schema for validating inputs
|
|
9
|
+
* @param outputSchema - Zod schema for validating outputs
|
|
10
|
+
* @param openaiConfig - OpenAI configuration
|
|
11
|
+
* @returns Async function that executes the agent with OpenAI chat completions
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import OpenAI from 'openai';
|
|
16
|
+
* import { nameGeneratorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
17
|
+
* import { convertLLMAnalyzerToFunction } from '@vibe-agent-toolkit/runtime-openai';
|
|
18
|
+
*
|
|
19
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
20
|
+
*
|
|
21
|
+
* const generateName = convertLLMAnalyzerToFunction(
|
|
22
|
+
* nameGeneratorAgent,
|
|
23
|
+
* NameGeneratorInputSchema,
|
|
24
|
+
* NameSuggestionSchema,
|
|
25
|
+
* {
|
|
26
|
+
* client: openai,
|
|
27
|
+
* model: 'gpt-4o-mini',
|
|
28
|
+
* temperature: 0.9,
|
|
29
|
+
* }
|
|
30
|
+
* );
|
|
31
|
+
*
|
|
32
|
+
* const result = await generateName({
|
|
33
|
+
* characteristics: {
|
|
34
|
+
* physical: { furColor: 'Orange' },
|
|
35
|
+
* behavioral: { personality: ['Distinguished'] },
|
|
36
|
+
* description: 'A noble cat',
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
* console.log(result.name); // "Sir Whiskersworth III"
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function convertLLMAnalyzerToFunction<TInput, TOutput>(agent: Agent<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>, openaiConfig: OpenAIConfig): (input: TInput) => Promise<TOutput>;
|
|
43
|
+
/**
|
|
44
|
+
* Batch converts multiple VAT LLM Analyzer agents to executable functions
|
|
45
|
+
*
|
|
46
|
+
* @param configs - Map of function names to conversion configurations
|
|
47
|
+
* @param openaiConfig - Shared OpenAI configuration for all agents
|
|
48
|
+
* @returns Map of function names to executable async functions
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* import OpenAI from 'openai';
|
|
53
|
+
*
|
|
54
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
55
|
+
*
|
|
56
|
+
* const functions = convertLLMAnalyzersToFunctions(
|
|
57
|
+
* {
|
|
58
|
+
* generateName: {
|
|
59
|
+
* agent: nameGeneratorAgent,
|
|
60
|
+
* inputSchema: NameGeneratorInputSchema,
|
|
61
|
+
* outputSchema: NameSuggestionSchema,
|
|
62
|
+
* },
|
|
63
|
+
* generateHaiku: {
|
|
64
|
+
* agent: haikuGeneratorAgent,
|
|
65
|
+
* inputSchema: HaikuGeneratorInputSchema,
|
|
66
|
+
* outputSchema: HaikuSchema,
|
|
67
|
+
* },
|
|
68
|
+
* },
|
|
69
|
+
* {
|
|
70
|
+
* client: openai,
|
|
71
|
+
* model: 'gpt-4o-mini',
|
|
72
|
+
* temperature: 0.8,
|
|
73
|
+
* }
|
|
74
|
+
* );
|
|
75
|
+
*
|
|
76
|
+
* const name = await functions.generateName(catInput);
|
|
77
|
+
* const haiku = await functions.generateHaiku(catInput);
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function convertLLMAnalyzersToFunctions(configs: LLMAnalyzerConversionConfigs, openaiConfig: OpenAIConfig): Record<string, (input: unknown) => Promise<unknown>>;
|
|
81
|
+
//# sourceMappingURL=llm-analyzer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-analyzer.d.ts","sourceRoot":"","sources":["../../src/adapters/llm-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,KAAK,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,4BAA4B,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI9E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAC1D,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAChC,YAAY,EAAE,YAAY,GACzB,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAsBrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,4BAA4B,EACrC,YAAY,EAAE,YAAY,GACzB,MAAM,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC,CAStD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { batchConvert } from '@vibe-agent-toolkit/agent-runtime';
|
|
2
|
+
import { createLLMAnalyzerCallLLM } from './common-helpers.js';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a VAT LLM Analyzer agent to an executable async function with OpenAI
|
|
5
|
+
*
|
|
6
|
+
* @param agent - The VAT LLM analyzer agent to convert
|
|
7
|
+
* @param inputSchema - Zod schema for validating inputs
|
|
8
|
+
* @param outputSchema - Zod schema for validating outputs
|
|
9
|
+
* @param openaiConfig - OpenAI configuration
|
|
10
|
+
* @returns Async function that executes the agent with OpenAI chat completions
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import OpenAI from 'openai';
|
|
15
|
+
* import { nameGeneratorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
16
|
+
* import { convertLLMAnalyzerToFunction } from '@vibe-agent-toolkit/runtime-openai';
|
|
17
|
+
*
|
|
18
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
19
|
+
*
|
|
20
|
+
* const generateName = convertLLMAnalyzerToFunction(
|
|
21
|
+
* nameGeneratorAgent,
|
|
22
|
+
* NameGeneratorInputSchema,
|
|
23
|
+
* NameSuggestionSchema,
|
|
24
|
+
* {
|
|
25
|
+
* client: openai,
|
|
26
|
+
* model: 'gpt-4o-mini',
|
|
27
|
+
* temperature: 0.9,
|
|
28
|
+
* }
|
|
29
|
+
* );
|
|
30
|
+
*
|
|
31
|
+
* const result = await generateName({
|
|
32
|
+
* characteristics: {
|
|
33
|
+
* physical: { furColor: 'Orange' },
|
|
34
|
+
* behavioral: { personality: ['Distinguished'] },
|
|
35
|
+
* description: 'A noble cat',
|
|
36
|
+
* },
|
|
37
|
+
* });
|
|
38
|
+
* console.log(result.name); // "Sir Whiskersworth III"
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export function convertLLMAnalyzerToFunction(agent, inputSchema, outputSchema, openaiConfig) {
|
|
42
|
+
// Create callLLM function that uses OpenAI chat completions
|
|
43
|
+
const callLLM = createLLMAnalyzerCallLLM(openaiConfig);
|
|
44
|
+
// Return wrapped function
|
|
45
|
+
return async (input) => {
|
|
46
|
+
// Validate input
|
|
47
|
+
const validatedInput = inputSchema.parse(input);
|
|
48
|
+
// Execute the agent with mock mode disabled (real LLM call)
|
|
49
|
+
const context = {
|
|
50
|
+
mockable: false,
|
|
51
|
+
model: openaiConfig.model,
|
|
52
|
+
temperature: openaiConfig.temperature ?? 0.7,
|
|
53
|
+
callLLM,
|
|
54
|
+
};
|
|
55
|
+
const output = await agent.execute(validatedInput, context);
|
|
56
|
+
// Validate output
|
|
57
|
+
return outputSchema.parse(output);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Batch converts multiple VAT LLM Analyzer agents to executable functions
|
|
62
|
+
*
|
|
63
|
+
* @param configs - Map of function names to conversion configurations
|
|
64
|
+
* @param openaiConfig - Shared OpenAI configuration for all agents
|
|
65
|
+
* @returns Map of function names to executable async functions
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* import OpenAI from 'openai';
|
|
70
|
+
*
|
|
71
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
72
|
+
*
|
|
73
|
+
* const functions = convertLLMAnalyzersToFunctions(
|
|
74
|
+
* {
|
|
75
|
+
* generateName: {
|
|
76
|
+
* agent: nameGeneratorAgent,
|
|
77
|
+
* inputSchema: NameGeneratorInputSchema,
|
|
78
|
+
* outputSchema: NameSuggestionSchema,
|
|
79
|
+
* },
|
|
80
|
+
* generateHaiku: {
|
|
81
|
+
* agent: haikuGeneratorAgent,
|
|
82
|
+
* inputSchema: HaikuGeneratorInputSchema,
|
|
83
|
+
* outputSchema: HaikuSchema,
|
|
84
|
+
* },
|
|
85
|
+
* },
|
|
86
|
+
* {
|
|
87
|
+
* client: openai,
|
|
88
|
+
* model: 'gpt-4o-mini',
|
|
89
|
+
* temperature: 0.8,
|
|
90
|
+
* }
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* const name = await functions.generateName(catInput);
|
|
94
|
+
* const haiku = await functions.generateHaiku(catInput);
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export function convertLLMAnalyzersToFunctions(configs, openaiConfig) {
|
|
98
|
+
return batchConvert(configs, (config) => convertLLMAnalyzerToFunction(config.agent, config.inputSchema, config.outputSchema, openaiConfig));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=llm-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm-analyzer.js","sourceRoot":"","sources":["../../src/adapters/llm-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAc,MAAM,mCAAmC,CAAC;AAK7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAA6B,EAC7B,WAA8B,EAC9B,YAAgC,EAChC,YAA0B;IAE1B,4DAA4D;IAC5D,MAAM,OAAO,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC;IAEvD,0BAA0B;IAC1B,OAAO,KAAK,EAAE,KAAa,EAAoB,EAAE;QAC/C,iBAAiB;QACjB,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEhD,4DAA4D;QAC5D,MAAM,OAAO,GAAG;YACd,QAAQ,EAAE,KAAK;YACf,KAAK,EAAE,YAAY,CAAC,KAAK;YACzB,WAAW,EAAE,YAAY,CAAC,WAAW,IAAI,GAAG;YAC5C,OAAO;SACR,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAE5D,kBAAkB;QAClB,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAqC,EACrC,YAA0B;IAE1B,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CACtC,4BAA4B,CAC1B,MAAM,CAAC,KAAgC,EACvC,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,YAAY,EACnB,YAAY,CACb,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { type PureFunctionAgent, type ToolConversionConfigs } from '@vibe-agent-toolkit/agent-runtime';
|
|
2
|
+
import type OpenAI from 'openai';
|
|
3
|
+
import type { z } from 'zod';
|
|
4
|
+
/**
|
|
5
|
+
* Converts a VAT Pure Function agent to OpenAI function calling tool definition
|
|
6
|
+
*
|
|
7
|
+
* @param agent - The VAT pure function agent to convert
|
|
8
|
+
* @param inputSchema - Zod schema for validating inputs
|
|
9
|
+
* @param outputSchema - Zod schema for validating outputs
|
|
10
|
+
* @returns OpenAI tool definition with metadata and executor
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import OpenAI from 'openai';
|
|
15
|
+
* import { haikuValidatorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
16
|
+
* import { convertPureFunctionToTool } from '@vibe-agent-toolkit/runtime-openai';
|
|
17
|
+
*
|
|
18
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
19
|
+
*
|
|
20
|
+
* const { tool, execute } = convertPureFunctionToTool(
|
|
21
|
+
* haikuValidatorAgent,
|
|
22
|
+
* HaikuSchema,
|
|
23
|
+
* HaikuValidationResultSchema
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* // Use with OpenAI chat completions
|
|
27
|
+
* const response = await openai.chat.completions.create({
|
|
28
|
+
* model: 'gpt-4o-mini',
|
|
29
|
+
* messages: [{ role: 'user', content: 'Validate this haiku...' }],
|
|
30
|
+
* tools: [tool],
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* // Execute tool calls
|
|
34
|
+
* for (const toolCall of response.choices[0].message.tool_calls ?? []) {
|
|
35
|
+
* const result = await execute(JSON.parse(toolCall.function.arguments));
|
|
36
|
+
* }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function convertPureFunctionToTool<TInput, TOutput>(agent: PureFunctionAgent<TInput, TOutput>, inputSchema: z.ZodType<TInput>, outputSchema: z.ZodType<TOutput>): {
|
|
40
|
+
tool: OpenAI.Chat.ChatCompletionTool;
|
|
41
|
+
execute: (args: TInput) => Promise<TOutput>;
|
|
42
|
+
metadata: {
|
|
43
|
+
name: string;
|
|
44
|
+
description: string;
|
|
45
|
+
version: string;
|
|
46
|
+
archetype: string;
|
|
47
|
+
};
|
|
48
|
+
inputSchema: z.ZodType<TInput>;
|
|
49
|
+
outputSchema: z.ZodType<TOutput>;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Batch converts multiple VAT Pure Function agents to OpenAI tools
|
|
53
|
+
*
|
|
54
|
+
* @param configs - Map of tool names to conversion configurations
|
|
55
|
+
* @returns Map of tool names to OpenAI tool definitions and executors
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const tools = convertPureFunctionsToTools({
|
|
60
|
+
* validateHaiku: {
|
|
61
|
+
* agent: haikuValidatorAgent,
|
|
62
|
+
* inputSchema: HaikuSchema,
|
|
63
|
+
* outputSchema: HaikuValidationResultSchema,
|
|
64
|
+
* },
|
|
65
|
+
* validateName: {
|
|
66
|
+
* agent: nameValidatorAgent,
|
|
67
|
+
* inputSchema: NameSchema,
|
|
68
|
+
* outputSchema: NameValidationResultSchema,
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
*
|
|
72
|
+
* // Use all tools with OpenAI
|
|
73
|
+
* const toolArray = Object.values(tools).map(t => t.tool);
|
|
74
|
+
* const response = await openai.chat.completions.create({
|
|
75
|
+
* model: 'gpt-4o-mini',
|
|
76
|
+
* messages: [{ role: 'user', content: 'Help me...' }],
|
|
77
|
+
* tools: toolArray,
|
|
78
|
+
* });
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function convertPureFunctionsToTools(configs: ToolConversionConfigs): Record<string, {
|
|
82
|
+
tool: OpenAI.Chat.ChatCompletionTool;
|
|
83
|
+
execute: (args: unknown) => Promise<unknown>;
|
|
84
|
+
metadata: {
|
|
85
|
+
name: string;
|
|
86
|
+
description: string;
|
|
87
|
+
version: string;
|
|
88
|
+
archetype: string;
|
|
89
|
+
};
|
|
90
|
+
}>;
|
|
91
|
+
//# sourceMappingURL=pure-function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure-function.d.ts","sourceRoot":"","sources":["../../src/adapters/pure-function.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,EACvD,KAAK,EAAE,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,EACzC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAC9B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,GAC/B;IACD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5C,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/B,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CAClC,CA4CA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,qBAAqB,GAC7B,MAAM,CACP,MAAM,EACN;IACE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;IACrC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACrF,CACF,CASA"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { batchConvert, } from '@vibe-agent-toolkit/agent-runtime';
|
|
2
|
+
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
3
|
+
/**
|
|
4
|
+
* Converts a VAT Pure Function agent to OpenAI function calling tool definition
|
|
5
|
+
*
|
|
6
|
+
* @param agent - The VAT pure function agent to convert
|
|
7
|
+
* @param inputSchema - Zod schema for validating inputs
|
|
8
|
+
* @param outputSchema - Zod schema for validating outputs
|
|
9
|
+
* @returns OpenAI tool definition with metadata and executor
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import OpenAI from 'openai';
|
|
14
|
+
* import { haikuValidatorAgent } from '@vibe-agent-toolkit/vat-example-cat-agents';
|
|
15
|
+
* import { convertPureFunctionToTool } from '@vibe-agent-toolkit/runtime-openai';
|
|
16
|
+
*
|
|
17
|
+
* const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
18
|
+
*
|
|
19
|
+
* const { tool, execute } = convertPureFunctionToTool(
|
|
20
|
+
* haikuValidatorAgent,
|
|
21
|
+
* HaikuSchema,
|
|
22
|
+
* HaikuValidationResultSchema
|
|
23
|
+
* );
|
|
24
|
+
*
|
|
25
|
+
* // Use with OpenAI chat completions
|
|
26
|
+
* const response = await openai.chat.completions.create({
|
|
27
|
+
* model: 'gpt-4o-mini',
|
|
28
|
+
* messages: [{ role: 'user', content: 'Validate this haiku...' }],
|
|
29
|
+
* tools: [tool],
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Execute tool calls
|
|
33
|
+
* for (const toolCall of response.choices[0].message.tool_calls ?? []) {
|
|
34
|
+
* const result = await execute(JSON.parse(toolCall.function.arguments));
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export function convertPureFunctionToTool(agent, inputSchema, outputSchema) {
|
|
39
|
+
const { manifest } = agent;
|
|
40
|
+
// Convert Zod schema to JSON Schema for OpenAI
|
|
41
|
+
const jsonSchema = zodToJsonSchema(inputSchema, {
|
|
42
|
+
name: manifest.name,
|
|
43
|
+
$refStrategy: 'none', // Inline all schemas
|
|
44
|
+
});
|
|
45
|
+
// Create OpenAI tool definition
|
|
46
|
+
const tool = {
|
|
47
|
+
type: 'function',
|
|
48
|
+
function: {
|
|
49
|
+
name: manifest.name,
|
|
50
|
+
description: manifest.description,
|
|
51
|
+
parameters: jsonSchema,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
// Create executor function
|
|
55
|
+
const execute = async (args) => {
|
|
56
|
+
// Validate input
|
|
57
|
+
const validatedInput = inputSchema.parse(args);
|
|
58
|
+
// Execute agent - returns output directly (unwrapped)
|
|
59
|
+
// The agent's execute wrapper validates input/output schemas and throws on error
|
|
60
|
+
const output = agent.execute(validatedInput);
|
|
61
|
+
// Validate the output with schema (redundant but explicit)
|
|
62
|
+
return outputSchema.parse(output);
|
|
63
|
+
};
|
|
64
|
+
return {
|
|
65
|
+
tool,
|
|
66
|
+
execute,
|
|
67
|
+
metadata: {
|
|
68
|
+
name: manifest.name,
|
|
69
|
+
description: manifest.description,
|
|
70
|
+
version: manifest.version,
|
|
71
|
+
archetype: manifest.archetype,
|
|
72
|
+
},
|
|
73
|
+
inputSchema,
|
|
74
|
+
outputSchema,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Batch converts multiple VAT Pure Function agents to OpenAI tools
|
|
79
|
+
*
|
|
80
|
+
* @param configs - Map of tool names to conversion configurations
|
|
81
|
+
* @returns Map of tool names to OpenAI tool definitions and executors
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const tools = convertPureFunctionsToTools({
|
|
86
|
+
* validateHaiku: {
|
|
87
|
+
* agent: haikuValidatorAgent,
|
|
88
|
+
* inputSchema: HaikuSchema,
|
|
89
|
+
* outputSchema: HaikuValidationResultSchema,
|
|
90
|
+
* },
|
|
91
|
+
* validateName: {
|
|
92
|
+
* agent: nameValidatorAgent,
|
|
93
|
+
* inputSchema: NameSchema,
|
|
94
|
+
* outputSchema: NameValidationResultSchema,
|
|
95
|
+
* },
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Use all tools with OpenAI
|
|
99
|
+
* const toolArray = Object.values(tools).map(t => t.tool);
|
|
100
|
+
* const response = await openai.chat.completions.create({
|
|
101
|
+
* model: 'gpt-4o-mini',
|
|
102
|
+
* messages: [{ role: 'user', content: 'Help me...' }],
|
|
103
|
+
* tools: toolArray,
|
|
104
|
+
* });
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export function convertPureFunctionsToTools(configs) {
|
|
108
|
+
return batchConvert(configs, (config) => {
|
|
109
|
+
const { tool, execute, metadata } = convertPureFunctionToTool(config.agent, config.inputSchema, config.outputSchema);
|
|
110
|
+
return { tool, execute, metadata };
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=pure-function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pure-function.js","sourceRoot":"","sources":["../../src/adapters/pure-function.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAGb,MAAM,mCAAmC,CAAC;AAG3C,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,yBAAyB,CACvC,KAAyC,EACzC,WAA8B,EAC9B,YAAgC;IAahC,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAE3B,+CAA+C;IAC/C,MAAM,UAAU,GAAG,eAAe,CAAC,WAAW,EAAE;QAC9C,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,YAAY,EAAE,MAAM,EAAE,qBAAqB;KAC5C,CAAC,CAAC;IAEH,gCAAgC;IAChC,MAAM,IAAI,GAAmC;QAC3C,IAAI,EAAE,UAAU;QAChB,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,UAAU,EAAE,UAAqC;SAClD;KACF,CAAC;IAEF,2BAA2B;IAC3B,MAAM,OAAO,GAAG,KAAK,EAAE,IAAY,EAAoB,EAAE;QACvD,iBAAiB;QACjB,MAAM,cAAc,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAE/C,sDAAsD;QACtD,iFAAiF;QACjF,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAE7C,2DAA2D;QAC3D,OAAO,YAAY,CAAC,KAAK,CAAC,MAAM,CAAY,CAAC;IAC/C,CAAC,CAAC;IAEF,OAAO;QACL,IAAI;QACJ,OAAO;QACP,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,SAAS,EAAE,QAAQ,CAAC,SAAS;SAC9B;QACD,WAAW;QACX,YAAY;KACb,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAA8B;IAS9B,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE;QACtC,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,yBAAyB,CAC3D,MAAM,CAAC,KAA4C,EACnD,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,YAAY,CACpB,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wCAAwC,CAAC;AAGvD,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,WAAW;AACX,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wCAAwC,CAAC;AAEvD,QAAQ;AACR,cAAc,YAAY,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type OpenAI from 'openai';
|
|
2
|
+
/**
|
|
3
|
+
* OpenAI configuration for VAT agents
|
|
4
|
+
*/
|
|
5
|
+
export interface OpenAIConfig {
|
|
6
|
+
/**
|
|
7
|
+
* OpenAI client instance
|
|
8
|
+
*/
|
|
9
|
+
client: OpenAI;
|
|
10
|
+
/**
|
|
11
|
+
* Model to use (e.g., 'gpt-4o-mini', 'gpt-4o')
|
|
12
|
+
*/
|
|
13
|
+
model: string;
|
|
14
|
+
/**
|
|
15
|
+
* Temperature for text generation (0-2)
|
|
16
|
+
* Higher values make output more random, lower values more deterministic
|
|
17
|
+
*/
|
|
18
|
+
temperature?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Maximum tokens to generate
|
|
21
|
+
*/
|
|
22
|
+
maxTokens?: number;
|
|
23
|
+
/**
|
|
24
|
+
* Additional model-specific settings
|
|
25
|
+
*/
|
|
26
|
+
additionalSettings?: Omit<OpenAI.Chat.ChatCompletionCreateParamsNonStreaming, 'model' | 'messages' | 'temperature' | 'max_tokens'>;
|
|
27
|
+
}
|
|
28
|
+
export type { LLMAnalyzerConversionConfig, LLMAnalyzerConversionConfigs, ToolConversionConfig, ToolConversionConfigs, } from '@vibe-agent-toolkit/agent-runtime';
|
|
29
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,kBAAkB,CAAC,EAAE,IAAI,CACvB,MAAM,CAAC,IAAI,CAAC,sCAAsC,EAClD,OAAO,GAAG,UAAU,GAAG,aAAa,GAAG,YAAY,CACpD,CAAC;CACH;AAGD,YAAY,EACV,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,mCAAmC,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vibe-agent-toolkit/runtime-openai",
|
|
3
|
+
"version": "0.1.2-rc.3",
|
|
4
|
+
"description": "OpenAI SDK runtime adapter for VAT agents",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"default": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"demo": "tsx examples/demo.ts",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest",
|
|
20
|
+
"test:llm-regression": "RUN_LLM_TESTS=true bun test test/llm-regression.test.ts",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@vibe-agent-toolkit/agent-runtime": "0.1.2-rc.3",
|
|
25
|
+
"openai": "^4.77.3",
|
|
26
|
+
"zod": "^3.24.1",
|
|
27
|
+
"zod-to-json-schema": "^3.24.1"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^22.10.5",
|
|
31
|
+
"@vibe-agent-toolkit/dev-tools": "0.1.2-rc.3",
|
|
32
|
+
"@vibe-agent-toolkit/vat-example-cat-agents": "0.1.2-rc.3",
|
|
33
|
+
"tsx": "^4.19.2",
|
|
34
|
+
"typescript": "^5.7.3",
|
|
35
|
+
"vitest": "^2.1.8"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"ai-agent",
|
|
39
|
+
"openai",
|
|
40
|
+
"vibe-agent-toolkit",
|
|
41
|
+
"runtime-adapter"
|
|
42
|
+
],
|
|
43
|
+
"author": "Jeff Dutton",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/jdutton/vibe-agent-toolkit.git",
|
|
48
|
+
"directory": "packages/runtime-openai"
|
|
49
|
+
}
|
|
50
|
+
}
|