@sweetoburrito/backstage-plugin-ai-assistant-backend 0.4.0 → 0.4.3
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.
|
@@ -15,7 +15,7 @@ Rules:
|
|
|
15
15
|
const createPromptBuilder = ({
|
|
16
16
|
config
|
|
17
17
|
}) => {
|
|
18
|
-
const system = config.getOptionalString("system") || DEFAULT_SYSTEM_PROMPT;
|
|
18
|
+
const system = config.getOptionalString("aiAssistant.prompt.system") || DEFAULT_SYSTEM_PROMPT;
|
|
19
19
|
const getContext = (context) => {
|
|
20
20
|
return `
|
|
21
21
|
Context:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.cjs.js","sources":["../../src/services/prompt.ts"],"sourcesContent":["import { RootConfigService } from '@backstage/backend-plugin-api';\nimport { EmbeddingDocument } from '@sweetoburrito/backstage-plugin-ai-assistant-node';\n\nimport { Message } from '@sweetoburrito/backstage-plugin-ai-assistant-common';\n\ntype PromptBuilderOptions = {\n config: RootConfigService;\n};\n\nexport type PromptBuilder = {\n buildPrompt: (\n chatHistory: Message[],\n promptContext: EmbeddingDocument[],\n ) => Message[];\n};\n\nconst DEFAULT_SYSTEM_PROMPT = `\nYou are a helpful assistant that answers questions based on provided context from various documents. The context may come from sources such as internal wikis, code repositories, technical documentation, or other structured or unstructured data.\n\nRules:\n1. Always base your answers on the provided context. Do not make up information.\n2. When relevant, cite or reference the source information provided in the context.\n3. Format answers clearly and concisely. Use bullet points for lists when appropriate.\n4. Maintain a professional, friendly, and helpful tone.\n5. Return only the relevant information without any filler or unnecessary details.\n6. If you don't know the answer, admit it and suggest ways to find the information.\n7. Always return a well-structured response using markdown.\n`;\n\nexport const createPromptBuilder = ({\n config,\n}: PromptBuilderOptions): PromptBuilder => {\n const system
|
|
1
|
+
{"version":3,"file":"prompt.cjs.js","sources":["../../src/services/prompt.ts"],"sourcesContent":["import { RootConfigService } from '@backstage/backend-plugin-api';\nimport { EmbeddingDocument } from '@sweetoburrito/backstage-plugin-ai-assistant-node';\n\nimport { Message } from '@sweetoburrito/backstage-plugin-ai-assistant-common';\n\ntype PromptBuilderOptions = {\n config: RootConfigService;\n};\n\nexport type PromptBuilder = {\n buildPrompt: (\n chatHistory: Message[],\n promptContext: EmbeddingDocument[],\n ) => Message[];\n};\n\nconst DEFAULT_SYSTEM_PROMPT = `\nYou are a helpful assistant that answers questions based on provided context from various documents. The context may come from sources such as internal wikis, code repositories, technical documentation, or other structured or unstructured data.\n\nRules:\n1. Always base your answers on the provided context. Do not make up information.\n2. When relevant, cite or reference the source information provided in the context.\n3. Format answers clearly and concisely. Use bullet points for lists when appropriate.\n4. Maintain a professional, friendly, and helpful tone.\n5. Return only the relevant information without any filler or unnecessary details.\n6. If you don't know the answer, admit it and suggest ways to find the information.\n7. Always return a well-structured response using markdown.\n`;\n\nexport const createPromptBuilder = ({\n config,\n}: PromptBuilderOptions): PromptBuilder => {\n const system =\n config.getOptionalString('aiAssistant.prompt.system') ||\n DEFAULT_SYSTEM_PROMPT;\n\n const getContext = (context: EmbeddingDocument[]) => {\n return `\n Context:\n ${context.map(doc => JSON.stringify(doc)).join('\\n')}\n `;\n };\n\n const buildPrompt: PromptBuilder['buildPrompt'] = (\n chatHistory,\n promptContext,\n ) => {\n const context = getContext(promptContext);\n\n return [\n {\n role: 'system',\n content: system.concat(context),\n },\n ...chatHistory,\n ];\n };\n\n return {\n buildPrompt,\n };\n};\n"],"names":[],"mappings":";;AAgBA,MAAM,qBAAA,GAAwB;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;AAavB,MAAM,sBAAsB,CAAC;AAAA,EAClC;AACF,CAAA,KAA2C;AACzC,EAAA,MAAM,MAAA,GACJ,MAAA,CAAO,iBAAA,CAAkB,2BAA2B,CAAA,IACpD,qBAAA;AAEF,EAAA,MAAM,UAAA,GAAa,CAAC,OAAA,KAAiC;AACnD,IAAA,OAAO;AAAA;AAAA,IAAA,EAEL,OAAA,CAAQ,GAAA,CAAI,CAAA,GAAA,KAAO,IAAA,CAAK,SAAA,CAAU,GAAG,CAAC,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC;AAAA,IAAA,CAAA;AAAA,EAEtD,CAAA;AAEA,EAAA,MAAM,WAAA,GAA4C,CAChD,WAAA,EACA,aAAA,KACG;AACH,IAAA,MAAM,OAAA,GAAU,WAAW,aAAa,CAAA;AAExC,IAAA,OAAO;AAAA,MACL;AAAA,QACE,IAAA,EAAM,QAAA;AAAA,QACN,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,OAAO;AAAA,OAChC;AAAA,MACA,GAAG;AAAA,KACL;AAAA,EACF,CAAA;AAEA,EAAA,OAAO;AAAA,IACL;AAAA,GACF;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sweetoburrito/backstage-plugin-ai-assistant-backend",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@backstage/plugin-signals-node": "backstage:^",
|
|
40
40
|
"@langchain/core": "^0.3.72",
|
|
41
41
|
"@langchain/textsplitters": "^0.1.0",
|
|
42
|
-
"@sweetoburrito/backstage-plugin-ai-assistant-common": "
|
|
43
|
-
"@sweetoburrito/backstage-plugin-ai-assistant-node": "
|
|
42
|
+
"@sweetoburrito/backstage-plugin-ai-assistant-common": "^0.2.2",
|
|
43
|
+
"@sweetoburrito/backstage-plugin-ai-assistant-node": "^0.3.2",
|
|
44
44
|
"express": "^4.17.1",
|
|
45
45
|
"express-promise-router": "^4.1.0",
|
|
46
46
|
"knex": "^3.1.0",
|
|
@@ -55,10 +55,10 @@
|
|
|
55
55
|
"@backstage/plugin-catalog-backend": "backstage:^",
|
|
56
56
|
"@backstage/plugin-signals-backend": "backstage:^",
|
|
57
57
|
"@backstage/types": "backstage:^",
|
|
58
|
-
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-embeddings-provider-ollama": "
|
|
59
|
-
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-ingestor-catalog": "
|
|
60
|
-
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-model-provider-azure-ai": "
|
|
61
|
-
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-model-provider-ollama": "
|
|
58
|
+
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-embeddings-provider-ollama": "^0.3.2",
|
|
59
|
+
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-ingestor-catalog": "^0.3.2",
|
|
60
|
+
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-model-provider-azure-ai": "^0.3.2",
|
|
61
|
+
"@sweetoburrito/backstage-plugin-ai-assistant-backend-module-model-provider-ollama": "^0.3.2",
|
|
62
62
|
"@types/express": "^4.0.0",
|
|
63
63
|
"@types/supertest": "^2.0.12",
|
|
64
64
|
"supertest": "^6.2.4"
|