feat: add prompt level config (#7445)

This commit is contained in:
darkskygit
2024-07-08 08:11:22 +00:00
parent 9ef8829ef1
commit bf6c9a5955
12 changed files with 125 additions and 41 deletions
@@ -676,7 +676,7 @@ test.skip('should be able to preview workflow', async t => {
registerCopilotProvider(OpenAIProvider);
for (const p of prompts) {
await prompt.set(p.name, p.model, p.messages);
await prompt.set(p.name, p.model, p.messages, p.config);
}
let result = '';
@@ -726,7 +726,7 @@ test('should be able to run pre defined workflow', async t => {
const { graph, prompts, callCount, input, params, result } = testCase;
console.log('running workflow test:', graph.name);
for (const p of prompts) {
await prompt.set(p.name, p.model, p.messages);
await prompt.set(p.name, p.model, p.messages, p.config);
}
for (const [idx, i] of input.entries()) {
@@ -773,7 +773,7 @@ test('should be able to run workflow', async t => {
const executor = Sinon.spy(executors.text, 'next');
for (const p of prompts) {
await prompt.set(p.name, p.model, p.messages);
await prompt.set(p.name, p.model, p.messages, p.config);
}
const graphName = 'presentation';
@@ -17,6 +17,7 @@ import {
CopilotTextToEmbeddingProvider,
CopilotTextToImageProvider,
CopilotTextToTextProvider,
PromptConfig,
PromptMessage,
} from '../../src/plugins/copilot/types';
import { NodeExecutorType } from '../../src/plugins/copilot/workflow/executor';
@@ -383,7 +384,12 @@ export async function getHistories(
return res.body.data.currentUser?.copilot?.histories || [];
}
type Prompt = { name: string; model: string; messages: PromptMessage[] };
type Prompt = {
name: string;
model: string;
messages: PromptMessage[];
config?: PromptConfig;
};
type WorkflowTestCase = {
graph: WorkflowGraph;
prompts: Prompt[];