@base44-preview/sdk 0.8.37-pr.226.49a8ffd → 0.8.37-pr.226.6c62736
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.
|
@@ -47,41 +47,26 @@ export interface AiGatewayModule {
|
|
|
47
47
|
*
|
|
48
48
|
* @example
|
|
49
49
|
* ```typescript
|
|
50
|
-
*
|
|
51
|
-
* import {
|
|
52
|
-
* import { z } from "zod";
|
|
50
|
+
* // Inside a backend function: hand the connection to any OpenAI-compatible client
|
|
51
|
+
* import { createClientFromRequest } from 'npm:@base44/sdk';
|
|
53
52
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* const models = createOpenAICompatible({ name: "base44", baseURL, apiKey: token });
|
|
53
|
+
* Deno.serve(async (req) => {
|
|
54
|
+
* const base44 = createClientFromRequest(req);
|
|
55
|
+
* const { baseURL, token } = base44.aiGateway.connection();
|
|
58
56
|
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* inputSchema: z.object({ status: z.string().optional() }),
|
|
68
|
-
* execute: ({ status }) => {
|
|
69
|
-
* const query = { customer_email: request.customer_email };
|
|
70
|
-
* if (status) query.status = status;
|
|
71
|
-
* return base44.entities.Order.filter(query, "-created_date", 50);
|
|
72
|
-
* },
|
|
57
|
+
* // Point any OpenAI-compatible client at `baseURL` with `apiKey: token`.
|
|
58
|
+
* // Shown here with a raw request to the Chat Completions endpoint:
|
|
59
|
+
* const res = await fetch(`${baseURL}/chat/completions`, {
|
|
60
|
+
* method: 'POST',
|
|
61
|
+
* headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${token}` },
|
|
62
|
+
* body: JSON.stringify({
|
|
63
|
+
* model: 'claude_sonnet_4_6',
|
|
64
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
73
65
|
* }),
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* execute: ({ decision, reason }) =>
|
|
78
|
-
* base44.entities.ReturnRequest.update(returnId, { status: decision, review_note: reason }),
|
|
79
|
-
* }),
|
|
80
|
-
* },
|
|
81
|
-
* stopWhen: [stepCountIs(8), hasToolCall("submitVerdict")],
|
|
66
|
+
* });
|
|
67
|
+
* const data = await res.json();
|
|
68
|
+
* return Response.json({ text: data.choices[0].message.content });
|
|
82
69
|
* });
|
|
83
|
-
*
|
|
84
|
-
* await agent.generate({ prompt: `Review this return request: ${JSON.stringify(request)}` });
|
|
85
70
|
* ```
|
|
86
71
|
*/
|
|
87
72
|
connection(): AiGatewayConnection;
|