Skip to content

Commit

Permalink
Revert "chore: Cleanup runConfigId / input merging (#179)" (#181)
Browse files Browse the repository at this point in the history
This reverts commit 05fbcfa.
  • Loading branch information
johnjcsmith authored Dec 1, 2024
1 parent df6809d commit 873dcd9
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 33 deletions.
16 changes: 2 additions & 14 deletions control-plane/src/modules/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,29 +524,17 @@ export const definition = {
.describe(
"When provided, the run will be marked as as a test / evaluation",
),
configId: z
.string()
.optional()
.describe("The run configuration ID to use"),
input: z
.object({})
.passthrough()
.describe(
"Structured input arguments to merge with the initial prompt. The schema must match the run configuration input schema if defined",
)
.optional(),
config: z
.object({
id: z.string().describe("DEPRECATED"),
id: z.string().describe("The run configuration ID"),
input: z
.object({})
.passthrough()
.describe(
"DEPRECATED",
"The run configuration input arguments, the schema must match the run configuration input schema",
)
.optional(),
})
.describe("DEPRECATED")
.optional(),
context: anyObject
.optional()
Expand Down
29 changes: 29 additions & 0 deletions control-plane/src/modules/prompt-templates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,5 +196,34 @@ describe("prompt-templates", () => {
},
});
});

it("should merge initialPrompt with run input", () => {
const options = {
input: {
name: "World",
},
};

const runConfig = {
id: "test-id",
name: "test-template",
initialPrompt: "Hello: ",
inputSchema: {
type: "object",
required: ["name"],
properties: {
name: { type: "string" },
extra: { type: "string" },
},
},
versions: [],
} as any;

const result = mergeRunConfigOptions(options, runConfig);

expect(result.error).toBeNull();
expect(result.options?.initialPrompt).toContain("Hello");
expect(result.options?.initialPrompt).toContain("World");
});
});
});
4 changes: 4 additions & 0 deletions control-plane/src/modules/prompt-templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ export const mergeRunConfigOptions = (
}
}

if (options.input) {
mergedOptions.initialPrompt = `${mergedOptions.initialPrompt}\n\n<DATA>\n${JSON.stringify(options.input, null, 2)}\n</DATA>`;
}

mergedOptions.messageMetadata = {
displayable: {
templateName: runConfig.name,
Expand Down
24 changes: 5 additions & 19 deletions control-plane/src/modules/workflows/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,12 @@ export const runsRouter = initServer().router(
await auth.canAccess({ cluster: { clusterId } });
auth.canCreate({ run: true });

// TODO: Remove once use of deprecated fields is removed
if (body.config) {
logger.info("Depreacted `run.config` provided in call to createRun");
body.configId = body.configId ?? body.config.id;
body.input = body.input ?? body.config.input;
}

// TODO: Remove once use of deprecated fields is removed
if (body.template) {
logger.info("Depreacted `run.template` provided in call to createRun");
body.configId = body.configId ?? body.template.id;
body.input = body.input ?? body.template.input;
body.config = body.template;
}

if (!body.initialPrompt && !body.configId) {
if (!body.initialPrompt && !body.config) {
return {
status: 400,
body: {
Expand Down Expand Up @@ -133,13 +124,13 @@ export const runsRouter = initServer().router(
callSummarization: body.callSummarization,
reasoningTraces: body.reasoningTraces,

input: body.input,
input: body.config?.input,
};

const runConfig = body.configId
const runConfig = body.config
? await getRunConfig({
clusterId,
id: body.configId,
id: body.config.id,
})
: undefined;

Expand All @@ -157,11 +148,6 @@ export const runsRouter = initServer().router(
runOptions = merged.options;
}

if (runOptions.input) {
runOptions.initialPrompt = `${runOptions.initialPrompt}\n\n<DATA>\n${JSON.stringify(runOptions.input, null, 2)}\n</DATA>`;
}


if (!runOptions.initialPrompt) {
throw new Error("Failed to construct initialPrompt");
}
Expand Down

0 comments on commit 873dcd9

Please sign in to comment.