-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrowser-agent-config.ts
More file actions
64 lines (58 loc) · 1.5 KB
/
browser-agent-config.ts
File metadata and controls
64 lines (58 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Browser-specific agent configuration helpers
* Provides default configuration for browser extension use cases
*/
import type { AppSettings } from "@aipexstudio/aipex-core";
import { aisdk, SessionStorage } from "@aipexstudio/aipex-core";
import { createAIProvider } from "@aipexstudio/aipex-react";
import { SYSTEM_PROMPT } from "@aipexstudio/aipex-react/components/chatbot/constants";
import {
allBrowserProviders,
allBrowserTools,
IndexedDBStorage,
} from "@aipexstudio/browser-runtime";
import { useCallback, useMemo } from "react";
/**
* Create browser-specific storage instance
*/
export function useBrowserStorage() {
return useMemo(
() =>
new SessionStorage(
new IndexedDBStorage({
dbName: "aipex-sessions",
storeName: "sessions",
}),
),
[],
);
}
/**
* Create browser-specific model factory
*/
export function useBrowserModelFactory() {
return useCallback((settings: AppSettings) => {
const provider = createAIProvider(settings);
return aisdk(provider(settings.aiModel!));
}, []);
}
/**
* Get browser-specific context providers
*/
export function useBrowserContextProviders() {
return useMemo(() => allBrowserProviders, []);
}
/**
* Get browser-specific tools
*/
export function useBrowserTools() {
return useMemo(() => allBrowserTools, []);
}
/**
* Browser-specific agent configuration
*/
export const BROWSER_AGENT_CONFIG = {
instructions: SYSTEM_PROMPT,
name: "AIPex Browser Assistant",
maxTurns: 200,
} as const;