-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestLlm.js
More file actions
65 lines (55 loc) · 2.02 KB
/
testLlm.js
File metadata and controls
65 lines (55 loc) · 2.02 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
65
import BosBase from "bosbase";
const baseUrl =
process.env.BOSBASE_BASE_URL ?? "http://127.0.0.1:8090";
const authEmail =
process.env.BOSBASE_EMAIL ??
process.env.BOSBASE_SUPERUSER_EMAIL ??
"try@bosbase.com";
const authPassword =
process.env.BOSBASE_PASSWORD ??
process.env.BOSBASE_SUPERUSER_PASSWORD ??
"bosbasepass";
const runLangChaingo = process.env.BOSBASE_RUN_LANGCHAINGO === "1";
const modelProvider = process.env.BOSBASE_LANGCHAINGO_PROVIDER;
const modelName = process.env.BOSBASE_LANGCHAINGO_MODEL;
async function main() {
try {
console.log("[INFO] LANGCHAINGO_API.md doc test starting...");
const pb = new BosBase(baseUrl);
await pb.collection("_superusers").authWithPassword(authEmail, authPassword);
console.log("[SUCCESS] Authenticated as superuser");
if (!pb.langchaingo) {
throw new Error("LangChaingo service is missing from the client");
}
console.log("[SUCCESS] LangChaingo service is available");
if (!runLangChaingo) {
console.log(
"[SKIP] Live LangChaingo calls skipped (set BOSBASE_RUN_LANGCHAINGO=1 to run completions).",
);
return;
}
const modelConfig =
modelProvider || modelName ? { provider: modelProvider, model: modelName } : undefined;
const completion = await pb.langchaingo.completions({
prompt: "Say hello from the LangChaingo JS SDK smoke test.",
model: modelConfig,
temperature: 0,
maxTokens: 32,
});
console.log("[SUCCESS] Completion content:", completion?.content || completion);
console.log("\n========== LANGCHAINGO_API.md doc test completed ==========");
} catch (error) {
console.error("[ERROR] LangChaingo doc test failed:");
if (error?.response) {
console.error("Status:", error.response.status);
console.error("Data:", JSON.stringify(error.response.data, null, 2));
if (error.response.data?.message) {
console.error("Message:", error.response.data.message);
}
} else {
console.error(error);
}
process.exit(1);
}
}
main();