mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
refactor(OpenAPIPlugin): add plugin prompt inspired by ChatGPT Invocator (#1023)
This commit is contained in:
parent
e7ca40b5ab
commit
d61e44742d
3 changed files with 9 additions and 5 deletions
|
|
@ -20,8 +20,8 @@ function createPrompt(name, functions) {
|
||||||
.map((func) => `// - ${func.name}: ${func.description}`)
|
.map((func) => `// - ${func.name}: ${func.description}`)
|
||||||
.join('\n');
|
.join('\n');
|
||||||
return `${prefix}\n${functionDescriptions}
|
return `${prefix}\n${functionDescriptions}
|
||||||
// The user's message will be passed as the function's query.
|
// You are an expert manager and scrum master. You must provide a detailed intent to better execute the function.
|
||||||
// Always provide the function name as such: {{"func": "function_name"}}`;
|
// Always format as such: {{"func": "function_name", "intent": "intent and expected result"}}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthBearer = z
|
const AuthBearer = z
|
||||||
|
|
@ -162,12 +162,16 @@ async function createOpenAPIPlugin({ data, llm, user, message, memory, signal, v
|
||||||
.map((func) => func.name)
|
.map((func) => func.name)
|
||||||
.join(', ')}`,
|
.join(', ')}`,
|
||||||
),
|
),
|
||||||
|
intent: z
|
||||||
|
.string()
|
||||||
|
.describe('Describe your intent with the function and your expected result'),
|
||||||
}),
|
}),
|
||||||
func: async ({ func = '' }) => {
|
func: async ({ func = '', intent = '' }) => {
|
||||||
const filteredFunctions = functions.filter((f) => f.name === func);
|
const filteredFunctions = functions.filter((f) => f.name === func);
|
||||||
chain.chains[0].lc_kwargs.llmKwargs.functions = filteredFunctions;
|
chain.chains[0].lc_kwargs.llmKwargs.functions = filteredFunctions;
|
||||||
|
const query = `${message}${func?.length > 0 ? `\n// Intent: ${intent}` : ''}`;
|
||||||
const result = await chain.call({
|
const result = await chain.call({
|
||||||
query: `${message}${func?.length > 0 ? `\nUse ${func}` : ''}`,
|
query,
|
||||||
signal,
|
signal,
|
||||||
});
|
});
|
||||||
return result.response;
|
return result.response;
|
||||||
|
|
|
||||||
BIN
bun.lockb
BIN
bun.lockb
Binary file not shown.
|
|
@ -47,7 +47,7 @@
|
||||||
"lint": "eslint \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
|
"lint": "eslint \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
|
||||||
"format": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
|
"format": "prettier-eslint --write \"{,!(node_modules)/**/}*.{js,jsx,ts,tsx}\"",
|
||||||
"b:api": "NODE_ENV=production bun run api/server/index.js",
|
"b:api": "NODE_ENV=production bun run api/server/index.js",
|
||||||
"b:api:dev": "NODE_ENV=development bun run --watch api/server/index.js",
|
"b:api:dev": "NODE_ENV=production bun run --watch api/server/index.js",
|
||||||
"b:data-provider": "cd packages/data-provider && bun run b:build",
|
"b:data-provider": "cd packages/data-provider && bun run b:build",
|
||||||
"b:client": "bun --bun run b:data-provider && cd client && bun --bun run b:build",
|
"b:client": "bun --bun run b:data-provider && cd client && bun --bun run b:build",
|
||||||
"b:client:dev": "cd client && bun run b:dev",
|
"b:client:dev": "cd client && bun run b:dev",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue