MCPcopy Create free account
hub / github.com/CaviraOSS/OpenReason / main

Function main

examples/code/provider-examples.ts:26–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

24}
25
26async function main() {
27 await runExample("openai", {
28 provider: "openai",
29 apiKey: process.env.OPENAI_API_KEY || "",
30 model: "gpt-4o",
31 simpleModel: "gpt-4o-mini",
32 complexModel: "gpt-4o"
33 }, "explain quantum entanglement");
34
35 await runExample("anthropic", {
36 provider: "anthropic",
37 apiKey: process.env.ANTHROPIC_API_KEY || "",
38 model: "claude-3-5-sonnet-20241022",
39 simpleModel: "claude-3-5-haiku-20241022"
40 }, "what is consciousness?");
41
42 await runExample("google", {
43 provider: "google",
44 apiKey: process.env.GOOGLE_API_KEY || "",
45 model: "gemini-1.5-pro",
46 simpleModel: "gemini-1.5-flash"
47 }, "summarize the theory of relativity");
48
49 const openaiQuery = "what is the meaning of life?";
50 const openaiKey = process.env.OPENAI_API_KEY || "";
51 const anthropicKey = process.env.ANTHROPIC_API_KEY || "";
52 if (openaiKey && anthropicKey) {
53 console.log("\n=== dynamic provider switching ===");
54 openreason.init({ provider: "openai", apiKey: openaiKey, model: "gpt-4o" });
55 const openaiResult = await openreason.reason(openaiQuery);
56 openreason.init({ provider: "anthropic", apiKey: anthropicKey, model: "claude-3-5-sonnet-20241022" });
57 const anthropicResult = await openreason.reason(openaiQuery);
58 console.log({ openai: openaiResult.confidence, anthropic: anthropicResult.confidence });
59 } else {
60 console.warn("Skipping dynamic provider comparison because both OPENAI_API_KEY and ANTHROPIC_API_KEY are required.");
61 }
62}
63
64main().catch(console.error);

Callers 1

Calls 1

runExampleFunction · 0.85

Tested by

no test coverage detected