@botonic/plugin-ai-agents 0.40.0-alpha.0 → 0.40.0
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/lib/cjs/agent-builder.d.ts +1 -1
- package/lib/cjs/agent-builder.js +11 -3
- package/lib/cjs/agent-builder.js.map +1 -1
- package/lib/cjs/hubtype-api-client.d.ts +1 -0
- package/lib/cjs/hubtype-api-client.js +19 -1
- package/lib/cjs/hubtype-api-client.js.map +1 -1
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +2 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/structured-output/carousel.d.ts +9 -9
- package/lib/cjs/structured-output/carousel.js +1 -1
- package/lib/cjs/structured-output/carousel.js.map +1 -1
- package/lib/cjs/structured-output/index.d.ts +36 -18
- package/lib/cjs/structured-output/text-with-buttons.d.ts +19 -5
- package/lib/cjs/structured-output/text-with-buttons.js +3 -1
- package/lib/cjs/structured-output/text-with-buttons.js.map +1 -1
- package/lib/cjs/tools/index.d.ts +1 -0
- package/lib/cjs/tools/index.js +3 -1
- package/lib/cjs/tools/index.js.map +1 -1
- package/lib/cjs/tools/retrieve-knowledge.d.ts +2 -0
- package/lib/cjs/tools/retrieve-knowledge.js +25 -0
- package/lib/cjs/tools/retrieve-knowledge.js.map +1 -0
- package/lib/cjs/types.d.ts +3 -14
- package/lib/esm/agent-builder.d.ts +1 -1
- package/lib/esm/agent-builder.js +12 -4
- package/lib/esm/agent-builder.js.map +1 -1
- package/lib/esm/hubtype-api-client.d.ts +1 -0
- package/lib/esm/hubtype-api-client.js +19 -1
- package/lib/esm/hubtype-api-client.js.map +1 -1
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +2 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/structured-output/carousel.d.ts +9 -9
- package/lib/esm/structured-output/carousel.js +1 -1
- package/lib/esm/structured-output/carousel.js.map +1 -1
- package/lib/esm/structured-output/index.d.ts +36 -18
- package/lib/esm/structured-output/text-with-buttons.d.ts +19 -5
- package/lib/esm/structured-output/text-with-buttons.js +3 -1
- package/lib/esm/structured-output/text-with-buttons.js.map +1 -1
- package/lib/esm/tools/index.d.ts +1 -0
- package/lib/esm/tools/index.js +1 -0
- package/lib/esm/tools/index.js.map +1 -1
- package/lib/esm/tools/retrieve-knowledge.d.ts +2 -0
- package/lib/esm/tools/retrieve-knowledge.js +22 -0
- package/lib/esm/tools/retrieve-knowledge.js.map +1 -0
- package/lib/esm/types.d.ts +3 -14
- package/package.json +3 -3
- package/src/agent-builder.ts +16 -5
- package/src/hubtype-api-client.ts +22 -1
- package/src/index.ts +4 -3
- package/src/structured-output/carousel.ts +1 -1
- package/src/structured-output/text-with-buttons.ts +5 -1
- package/src/tools/index.ts +1 -0
- package/src/tools/retrieve-knowledge.ts +27 -0
- package/src/types.ts +10 -13
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RunContext, tool } from '@openai/agents'
|
|
2
|
+
import { z } from 'zod'
|
|
3
|
+
|
|
4
|
+
import { HubtypeApiClient } from '../hubtype-api-client'
|
|
5
|
+
import { Context } from '../types'
|
|
6
|
+
|
|
7
|
+
export const retrieveKnowledge = tool<any, Context, any>({
|
|
8
|
+
name: 'retrieve_knowledge',
|
|
9
|
+
description:
|
|
10
|
+
'Consult the knowledge base for information before answering. Use this tool to make sure the information you provide is faithful.',
|
|
11
|
+
parameters: z.object({
|
|
12
|
+
query: z.string().describe('The query to search the knowledge base for'),
|
|
13
|
+
}),
|
|
14
|
+
execute: async (
|
|
15
|
+
{ query }: { query: string },
|
|
16
|
+
runContext?: RunContext<Context>
|
|
17
|
+
): Promise<string[]> => {
|
|
18
|
+
const context = runContext?.context
|
|
19
|
+
if (!context) {
|
|
20
|
+
throw new Error('Context is required')
|
|
21
|
+
}
|
|
22
|
+
const sources = context.sources
|
|
23
|
+
const client = new HubtypeApiClient(context.authToken)
|
|
24
|
+
const chunks = await client.retrieveSimilarChunks(query, sources)
|
|
25
|
+
return chunks
|
|
26
|
+
},
|
|
27
|
+
})
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgenticOutputMessage,
|
|
3
|
+
AiAgentArgs,
|
|
4
|
+
GuardrailRule,
|
|
3
5
|
InferenceResponse,
|
|
4
6
|
RunResult,
|
|
5
7
|
} from '@botonic/core'
|
|
@@ -15,6 +17,7 @@ import { OutputSchema } from './structured-output'
|
|
|
15
17
|
|
|
16
18
|
export interface Context {
|
|
17
19
|
authToken: string
|
|
20
|
+
sources: string[]
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
export type RunContext = OpenAIRunContext<Context>
|
|
@@ -26,11 +29,6 @@ export interface CustomTool {
|
|
|
26
29
|
func: (input?: any, runContext?: RunContext) => Promise<any>
|
|
27
30
|
}
|
|
28
31
|
|
|
29
|
-
export interface GuardrailRule {
|
|
30
|
-
name: string
|
|
31
|
-
description: string
|
|
32
|
-
}
|
|
33
|
-
|
|
34
32
|
export type ContactInfo = Record<string, string>
|
|
35
33
|
|
|
36
34
|
export type Tool = OpenAITool<Context>
|
|
@@ -40,13 +38,12 @@ export interface PluginAiAgentOptions {
|
|
|
40
38
|
customTools?: CustomTool[]
|
|
41
39
|
}
|
|
42
40
|
|
|
43
|
-
export interface AiAgentArgs {
|
|
44
|
-
name: string
|
|
45
|
-
instructions: string
|
|
46
|
-
activeTools?: { name: string }[]
|
|
47
|
-
inputGuardrailRules?: GuardrailRule[]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
41
|
export type AgenticInputMessage = AgentInputItem
|
|
51
42
|
|
|
52
|
-
export
|
|
43
|
+
export {
|
|
44
|
+
AgenticOutputMessage,
|
|
45
|
+
AiAgentArgs,
|
|
46
|
+
GuardrailRule,
|
|
47
|
+
InferenceResponse,
|
|
48
|
+
RunResult,
|
|
49
|
+
}
|