Skip to content

Commit

Permalink
Specify the response format using JSON Text Sequences for non-structu…
Browse files Browse the repository at this point in the history
…red output
  • Loading branch information
stefl committed Sep 13, 2024
1 parent 2e95d49 commit 748741b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/src/prompts/lesson-assistant/parts/interactive.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { TemplateProps } from "..";

const STRUCTURED_OUTPUTS_ENABLED =
process.env.NEXT_PUBLIC_STRUCTURED_OUTPUTS_ENABLED === "true" ? true : false;

const responseFormatWithStructuredOutputs = `{"response":"llmMessage", patches:[{},{}...], prompt:{}}`;
const responseFormatWithoutStructuredOutputs = `A series of JSON documents separated using the JSON Text Sequences specification, where each row is separated by the ␞ character and ends with a new line character.
Your response should be a series of patches followed by one and only one prompt to the user.`;

const responseFormat = STRUCTURED_OUTPUTS_ENABLED
? responseFormatWithStructuredOutputs
: responseFormatWithoutStructuredOutputs;
export const interactive = ({
llmResponseJsonSchema,
}: TemplateProps) => `RULES FOR RESPONDING TO THE USER INTERACTIVELY WHILE CREATING THE LESSON PLAN
Your response to the user should be in the following format.
{"response":"llmMessage", patches:[{},{}...], prompt:{}}
${responseFormat}
"prompt" is a JSON document which represents your message to the user.
"patches" is series of JSON documents that represent the changes you are making to the lesson plan presented in the form of a series of JSON documents separated using the JSON Text Sequences specification.
Expand Down

0 comments on commit 748741b

Please sign in to comment.