@dotbots-boutique/server-sdk 0.1.0 → 0.3.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/README.md +4 -3
- package/dist/client.d.ts +1 -1
- package/dist/client.js +15 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,8 @@ These are injected automatically by the DotBots platform — no manual configura
|
|
|
32
32
|
```
|
|
33
33
|
DOTBOTS_APP_ID=uuid
|
|
34
34
|
DOTBOTS_APP_SECRET=...
|
|
35
|
-
|
|
35
|
+
PLATFORM_API_URL=https://api.dotbots.ai
|
|
36
|
+
DOTBOTS_PROXY_URL=https://proxy.dotbots.ai
|
|
36
37
|
ENVIRONMENT=test|prod
|
|
37
38
|
```
|
|
38
39
|
|
|
@@ -46,7 +47,7 @@ import { DotBotsBackend } from 'npm:@dotbots-boutique/server-sdk';
|
|
|
46
47
|
const dotbots = new DotBotsBackend({
|
|
47
48
|
appId: Deno.env.get('DOTBOTS_APP_ID')!,
|
|
48
49
|
appSecret: Deno.env.get('DOTBOTS_APP_SECRET')!,
|
|
49
|
-
apiUrl: Deno.env.get('
|
|
50
|
+
apiUrl: Deno.env.get('PLATFORM_API_URL') ?? 'https://api.dotbots.ai',
|
|
50
51
|
environment: Deno.env.get('ENVIRONMENT') ?? 'prod'
|
|
51
52
|
});
|
|
52
53
|
|
|
@@ -54,7 +55,7 @@ const dotbots = new DotBotsBackend({
|
|
|
54
55
|
await dotbots.initialize();
|
|
55
56
|
```
|
|
56
57
|
|
|
57
|
-
`initialize()`
|
|
58
|
+
`initialize()` must be called before any other methods. If `DOTBOTS_PROXY_URL` is set, the proxy URL is used directly. Otherwise it fetches the proxy URL from the platform.
|
|
58
59
|
|
|
59
60
|
## AI calls
|
|
60
61
|
|
package/dist/client.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class DotBotsBackend {
|
|
|
7
7
|
private proxyUrl;
|
|
8
8
|
constructor(config: DotBotsBackendConfig);
|
|
9
9
|
initialize(): Promise<void>;
|
|
10
|
-
ai(feature: string, request: BackendAiRequest): Promise<AiResponse>;
|
|
10
|
+
ai(feature: string, request: BackendAiRequest, onDelta?: (delta: string) => void): Promise<AiResponse>;
|
|
11
11
|
aiStream(feature: string, request: BackendAiRequest, onDelta: (delta: string) => void, onDone?: (response: AiResponse) => void): Promise<void>;
|
|
12
12
|
charge(featureCode: string, options: {
|
|
13
13
|
paidBy?: 'org' | 'app';
|
package/dist/client.js
CHANGED
|
@@ -15,6 +15,15 @@ class DotBotsBackend {
|
|
|
15
15
|
this.environment = config.environment;
|
|
16
16
|
}
|
|
17
17
|
async initialize() {
|
|
18
|
+
const injectedProxyUrl = process.env.DOTBOTS_PROXY_URL;
|
|
19
|
+
if (injectedProxyUrl) {
|
|
20
|
+
this.proxyUrl = injectedProxyUrl;
|
|
21
|
+
console.log(JSON.stringify({
|
|
22
|
+
level: 'info',
|
|
23
|
+
message: `[DotBotsBackend] Proxy URL from env: ${injectedProxyUrl}`,
|
|
24
|
+
}));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
18
27
|
const response = await fetch(`${this.apiUrl}/api/proxy/config`, {
|
|
19
28
|
headers: this.baseHeaders(),
|
|
20
29
|
});
|
|
@@ -28,7 +37,12 @@ class DotBotsBackend {
|
|
|
28
37
|
message: `[DotBotsBackend] Proxy config loaded — proxyUrl: ${data.proxyUrl}`,
|
|
29
38
|
}));
|
|
30
39
|
}
|
|
31
|
-
async ai(feature, request) {
|
|
40
|
+
async ai(feature, request, onDelta) {
|
|
41
|
+
if (onDelta !== undefined) {
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
this.aiStream(feature, request, onDelta, resolve).catch(reject);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
32
46
|
const response = await fetch(`${this.getProxyUrl()}/ai/call`, {
|
|
33
47
|
method: 'POST',
|
|
34
48
|
headers: this.baseHeaders(),
|
|
@@ -38,7 +52,6 @@ class DotBotsBackend {
|
|
|
38
52
|
tools: request.tools,
|
|
39
53
|
stream: false,
|
|
40
54
|
maxTokens: request.maxTokens,
|
|
41
|
-
paidBy: request.paidBy,
|
|
42
55
|
orgId: request.orgId,
|
|
43
56
|
}),
|
|
44
57
|
});
|
package/package.json
CHANGED