From 499db3df4b9086773422f609bfbe5775d4c48143 Mon Sep 17 00:00:00 2001 From: LL Date: Sat, 9 Nov 2024 13:45:48 -0800 Subject: [PATCH] use local llm --- cofounder/api/package.json | 1 + cofounder/api/system/functions/backend/asyncapi.js | 2 +- cofounder/api/system/functions/backend/openapi.js | 4 ++-- cofounder/api/system/functions/backend/server.js | 2 +- cofounder/api/system/functions/db/postgres.js | 2 +- cofounder/api/system/functions/db/schemas.js | 2 +- cofounder/api/system/functions/designer/layoutv1.js | 6 +++--- cofounder/api/system/functions/op/llm.js | 4 +++- cofounder/api/system/functions/pm/brd.js | 2 +- cofounder/api/system/functions/pm/drd.js | 2 +- cofounder/api/system/functions/pm/fjmd.js | 2 +- cofounder/api/system/functions/pm/frd.js | 2 +- cofounder/api/system/functions/pm/prd.js | 2 +- cofounder/api/system/functions/pm/uxdmd.js | 2 +- cofounder/api/system/functions/pm/uxsmd.js | 2 +- cofounder/api/system/functions/swarm/augment.js | 4 ++-- cofounder/api/system/functions/ux/datamap.js | 4 ++-- cofounder/api/system/functions/ux/sitemap.js | 2 +- cofounder/api/system/functions/webapp/root.js | 2 +- cofounder/api/system/functions/webapp/store.js | 2 +- cofounder/api/system/functions/webapp/view.js | 8 ++++---- 21 files changed, 31 insertions(+), 28 deletions(-) diff --git a/cofounder/api/package.json b/cofounder/api/package.json index 3bb7f80..ad8b124 100644 --- a/cofounder/api/package.json +++ b/cofounder/api/package.json @@ -17,6 +17,7 @@ "@google-cloud/storage": "^7.12.1", "@resvg/resvg-js": "^2.6.2", "async-retry": "^1.3.3", + "axios": "^1.7.7", "colormap": "^2.3.2", "cors": "^2.8.5", "deepmerge": "^4.3.1", diff --git a/cofounder/api/system/functions/backend/asyncapi.js b/cofounder/api/system/functions/backend/asyncapi.js index d37f9f9..8ca1dc6 100644 --- a/cofounder/api/system/functions/backend/asyncapi.js +++ b/cofounder/api/system/functions/backend/asyncapi.js @@ -142,7 +142,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, diff --git a/cofounder/api/system/functions/backend/openapi.js b/cofounder/api/system/functions/backend/openapi.js index b2a5de3..f47c43d 100644 --- a/cofounder/api/system/functions/backend/openapi.js +++ b/cofounder/api/system/functions/backend/openapi.js @@ -100,7 +100,7 @@ ${prd} }, { role: "user", - content: `\`\`\`PRD:product-requirements-document + content: `\`\`\`FRD:features-requirements-document ${frd} \`\`\``, }, @@ -147,7 +147,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, diff --git a/cofounder/api/system/functions/backend/server.js b/cofounder/api/system/functions/backend/server.js index 581f55b..7aa8be4 100644 --- a/cofounder/api/system/functions/backend/server.js +++ b/cofounder/api/system/functions/backend/server.js @@ -297,7 +297,7 @@ now do the analysis , write the full working script and specify the dependencies }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messages, preparser: false, parser: false, diff --git a/cofounder/api/system/functions/db/postgres.js b/cofounder/api/system/functions/db/postgres.js index cc50e97..8346abd 100644 --- a/cofounder/api/system/functions/db/postgres.js +++ b/cofounder/api/system/functions/db/postgres.js @@ -108,7 +108,7 @@ you're a genius` }, }, data: { - model: `chatgpt-4o-latest`,//`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL,//`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/db/schemas.js b/cofounder/api/system/functions/db/schemas.js index b1f5ccc..5d39c58 100644 --- a/cofounder/api/system/functions/db/schemas.js +++ b/cofounder/api/system/functions/db/schemas.js @@ -123,7 +123,7 @@ you're a genius` }, }, data: { - model: `chatgpt-4o-latest`,//`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL,//`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, diff --git a/cofounder/api/system/functions/designer/layoutv1.js b/cofounder/api/system/functions/designer/layoutv1.js index 7f96a2f..5604ec2 100644 --- a/cofounder/api/system/functions/designer/layoutv1.js +++ b/cofounder/api/system/functions/designer/layoutv1.js @@ -461,7 +461,7 @@ async function designerLayoutv1ViewGenerate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: analysisPassMessages, preparser: `backticks`, parser: false, @@ -487,7 +487,7 @@ async function designerLayoutv1ViewGenerate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: svgPassMessages, preparser: false, parser: false, @@ -946,7 +946,7 @@ async function designerLayoutv1ViewIterate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: svgIterateMessages, preparser: false, parser: false, diff --git a/cofounder/api/system/functions/op/llm.js b/cofounder/api/system/functions/op/llm.js index 4a80a6d..c82a25f 100644 --- a/cofounder/api/system/functions/op/llm.js +++ b/cofounder/api/system/functions/op/llm.js @@ -57,9 +57,11 @@ async function opLlmGen({ context, data }) { parser = utils.parsers.parse.yaml; } + + let isOpenAi = process.env.LLM_PROVIDER.toLowerCase() === "local" || process.env.LLM_PROVIDER.toLowerCase() === "openai" const llm_fn = !process.env.LLM_PROVIDER ? utils.openai.inference - : process.env.LLM_PROVIDER.toLowerCase() === "openai" + : isOpenAi ? utils.openai.inference : utils.anthropic.inference; diff --git a/cofounder/api/system/functions/pm/brd.js b/cofounder/api/system/functions/pm/brd.js index dcf8724..c85cb17 100644 --- a/cofounder/api/system/functions/pm/brd.js +++ b/cofounder/api/system/functions/pm/brd.js @@ -315,7 +315,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/pm/drd.js b/cofounder/api/system/functions/pm/drd.js index f8cfd23..f3404b4 100644 --- a/cofounder/api/system/functions/pm/drd.js +++ b/cofounder/api/system/functions/pm/drd.js @@ -118,7 +118,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/pm/fjmd.js b/cofounder/api/system/functions/pm/fjmd.js index 86e51f4..4918f74 100644 --- a/cofounder/api/system/functions/pm/fjmd.js +++ b/cofounder/api/system/functions/pm/fjmd.js @@ -115,7 +115,7 @@ you're a genius`, id: "op:LLM::GEN", context, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, diff --git a/cofounder/api/system/functions/pm/frd.js b/cofounder/api/system/functions/pm/frd.js index 408dfe7..3a19430 100644 --- a/cofounder/api/system/functions/pm/frd.js +++ b/cofounder/api/system/functions/pm/frd.js @@ -84,7 +84,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/pm/prd.js b/cofounder/api/system/functions/pm/prd.js index f71ac7f..a16ca9c 100644 --- a/cofounder/api/system/functions/pm/prd.js +++ b/cofounder/api/system/functions/pm/prd.js @@ -105,7 +105,7 @@ you are a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/pm/uxdmd.js b/cofounder/api/system/functions/pm/uxdmd.js index 4d21a38..b94a70d 100644 --- a/cofounder/api/system/functions/pm/uxdmd.js +++ b/cofounder/api/system/functions/pm/uxdmd.js @@ -197,7 +197,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, // `chatgpt-4o-latest`,//`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, // `chatgpt-4o-latest`,//`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/pm/uxsmd.js b/cofounder/api/system/functions/pm/uxsmd.js index 3eb482c..02b15ce 100644 --- a/cofounder/api/system/functions/pm/uxsmd.js +++ b/cofounder/api/system/functions/pm/uxsmd.js @@ -143,7 +143,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages, preparser: `backticks`, parser: false, diff --git a/cofounder/api/system/functions/swarm/augment.js b/cofounder/api/system/functions/swarm/augment.js index a712666..3bc5213 100644 --- a/cofounder/api/system/functions/swarm/augment.js +++ b/cofounder/api/system/functions/swarm/augment.js @@ -320,7 +320,7 @@ async function swarmAugmentBackendExternalapis({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messagesAnalysis, preparser: `backticks`, parser: false, @@ -344,7 +344,7 @@ async function swarmAugmentBackendExternalapis({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messagesImplementMerge, preparser: false, parser: false, diff --git a/cofounder/api/system/functions/ux/datamap.js b/cofounder/api/system/functions/ux/datamap.js index 35c4e1f..448a132 100644 --- a/cofounder/api/system/functions/ux/datamap.js +++ b/cofounder/api/system/functions/ux/datamap.js @@ -162,7 +162,7 @@ ${uxdmd} }, }, data: { - model: `chatgpt-4o-latest`, //`chatgpt-4o-latest`, // `chatgpt-4o-latest`,//`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`chatgpt-4o-latest`, // `chatgpt-4o-latest`,//`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, @@ -490,7 +490,7 @@ you're a genius`, }, }, data: { - model: `chatgpt-4o-latest`, //`chatgpt-4o-latest`, // `chatgpt-4o-latest`,//`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`chatgpt-4o-latest`, // `chatgpt-4o-latest`,//`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, diff --git a/cofounder/api/system/functions/ux/sitemap.js b/cofounder/api/system/functions/ux/sitemap.js index 154eeb3..b81d931 100644 --- a/cofounder/api/system/functions/ux/sitemap.js +++ b/cofounder/api/system/functions/ux/sitemap.js @@ -104,7 +104,7 @@ You're a genius do a great job`, }, }, data: { - model: `chatgpt-4o-latest`, // `chatgpt-4o-latest`,//`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, // `chatgpt-4o-latest`,//`gpt-4o`, messages, preparser: `backticks`, parser: `yaml`, diff --git a/cofounder/api/system/functions/webapp/root.js b/cofounder/api/system/functions/webapp/root.js index ec126c5..43be885 100644 --- a/cofounder/api/system/functions/webapp/root.js +++ b/cofounder/api/system/functions/webapp/root.js @@ -205,7 +205,7 @@ async function webappRootGenerate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messages, preparser: false, parser: false, diff --git a/cofounder/api/system/functions/webapp/store.js b/cofounder/api/system/functions/webapp/store.js index 5788a62..f6437c9 100644 --- a/cofounder/api/system/functions/webapp/store.js +++ b/cofounder/api/system/functions/webapp/store.js @@ -205,7 +205,7 @@ async function webappStoreGenerate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messages, preparser: false, parser: false, diff --git a/cofounder/api/system/functions/webapp/view.js b/cofounder/api/system/functions/webapp/view.js index d3687f8..951db98 100644 --- a/cofounder/api/system/functions/webapp/view.js +++ b/cofounder/api/system/functions/webapp/view.js @@ -513,7 +513,7 @@ async function webappViewGenerate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messagesFunctional, preparser: false, parser: false, @@ -699,7 +699,7 @@ async function webappViewGenerate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: messagesRedesign, preparser: false, parser: false, @@ -1251,7 +1251,7 @@ async function webappViewIterate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: promptMessagesNoDesigner, preparser: false, parser: false, @@ -1415,7 +1415,7 @@ async function webappViewIterate({ context, data }) { }, }, data: { - model: `chatgpt-4o-latest`, //`gpt-4o`, + model: process.env.LOCAL_INFERENCE_MODEL, //`gpt-4o`, messages: mesagesIterateWithDesigner, preparser: false, parser: false,