-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Markdown and plaintext output systems #929
Changes from all commits
239f3af
745b456
81ca956
42db415
b80aa5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ System prompts are scripts that are executed and injected before the main prompt | |
- system prompts must use the `system` instead of `script` | ||
- system prompts are executed with the same environment as the main prompt | ||
|
||
```js title="system.zscot.genai.js" "system" | ||
```js title="system.zero_shot_cot.genai.js" "system" | ||
system({ | ||
title: "Zero-shot Chain of Thought", | ||
}) | ||
|
@@ -22,10 +22,10 @@ $`Let's think step by step.` | |
|
||
To use system prompts in script, populate the `system` field with script identifiers. | ||
|
||
```js title="myscript.genai.js" 'system: ["system.zscot"]' | ||
```js title="myscript.genai.js" 'system: ["system.zero_shot_cot"]' | ||
script({ | ||
..., | ||
system: ["system.zscot"] | ||
system: ["system.zero_shot_cot"] | ||
}) | ||
$`Let's think step by step.` | ||
``` | ||
|
@@ -73,6 +73,22 @@ script({ ..., | |
}) | ||
``` | ||
|
||
## Automated System Prompts | ||
|
||
When unspecified, GenAIScript inspects the source code of the script | ||
to determine a reasonable set of system prompts ([source code](https://github.com/microsoft/genaiscript/blob/main/packages/core/src/systems.ts)). | ||
|
||
The default mix is | ||
|
||
- system | ||
- system.output_markdown | ||
- system.explanations | ||
- system.safety_jailbreak | ||
- system.safety_harmful_content | ||
- system.safety_protected_material | ||
|
||
On top of the default, injects other system scripts based on keyword matching. | ||
|
||
## Builtin System Prompts | ||
|
||
GenAIScript comes with a number of system prompt that support features like creating files, extracting diffs or | ||
|
@@ -88,9 +104,7 @@ Base system prompt | |
|
||
`````js wrap title="system" | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
system({ title: "Base system prompt" }) | ||
$`- You are concise. | ||
- Answer in markdown. | ||
` | ||
$`- You are concise.` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The markdown syntax for code blocks should be consistent. Use triple backticks (```) instead of ````` to define code blocks.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The markdown syntax for code blocks should be consistent. Use triple backticks (```) instead of ````` to define code blocks.
|
||
|
||
````` | ||
|
||
|
@@ -2567,6 +2581,39 @@ defTool( | |
````` | ||
|
||
|
||
### `system.output_markdown` | ||
|
||
Base system prompt | ||
|
||
|
||
|
||
|
||
|
||
`````js wrap title="system.output_markdown" | ||
system({ title: "Base system prompt" }) | ||
$`## Markdown Output | ||
Respond in Markdown (GitHub Flavored Markdown also supported).` | ||
|
||
````` | ||
|
||
|
||
### `system.output_plaintext` | ||
|
||
Plain text output | ||
|
||
|
||
|
||
|
||
|
||
`````js wrap title="system.output_plaintext" | ||
system({ title: "Plain text output" }) | ||
$`## Plain Text Output | ||
Respond in plain text. Do not wrap result in Markdown code fences or XML tags. | ||
` | ||
|
||
````` | ||
|
||
|
||
### `system.planner` | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The headings for the new sections should be consistent with the existing headings. Use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippets within the new sections are not properly formatted. Ensure that each snippet is enclosed in triple backticks (```) and has a language identifier if applicable.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The links within the code snippets should be consistent with the existing documentation. Ensure that all links are properly formatted and accessible.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tables within the new sections are not properly formatted. Ensure that each table is enclosed in triple backticks (```) and has a header row if applicable.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lists within the new sections should be consistent with the existing documentation. Ensure that all lists are properly formatted and have proper indentation.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The quotes within the code snippets should be consistent with the existing documentation. Ensure that all quotes are properly formatted and do not interfere with the syntax of the code.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The structure of the documentation is inconsistent. The new sections
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The headings for the new sections should be consistent with the existing headings. Use
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code snippets within the new sections are not properly formatted. Ensure that each snippet is enclosed in triple backticks (```) and has a language identifier if applicable.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The links within the code snippets should be consistent with the existing documentation. Ensure that all links are properly formatted and accessible.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tables within the new sections are not properly formatted. Ensure that each table is enclosed in triple backticks (```) and has a header row if applicable.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The lists within the new sections should be consistent with the existing documentation. Ensure that all lists are properly formatted and have proper indentation.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The quotes within the code snippets should be consistent with the existing documentation. Ensure that all quotes are properly formatted and do not interfere with the syntax of the code.
|
||
|
||
Instruct to make a plan | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,13 +54,12 @@ | |
export const SMALL_MODEL_ID = "small" | ||
export const LARGE_MODEL_ID = "large" | ||
export const VISION_MODEL_ID = "vision" | ||
export const DEFAULT_FENCE_FORMAT: FenceFormat = "xml" | ||
export const DEFAULT_MODEL = "openai:gpt-4o" | ||
export const DEFAULT_MODEL_CANDIDATES = [ | ||
"azure:gpt-4o", | ||
"azure_serverless:gpt-4o", | ||
DEFAULT_MODEL, | ||
"google:gemini-1.5-pro-latest", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The export
|
||
"anthropic:claude-2.1", | ||
"mistral:mistral-large-latest", | ||
"github:gpt-4o", | ||
|
@@ -68,7 +67,6 @@ | |
] | ||
export const DEFAULT_VISION_MODEL = "openai:gpt-4o" | ||
export const DEFAULT_VISION_MODEL_CANDIDATES = [ | ||
"azure:gpt-4o", | ||
"azure_serverless:gpt-4o", | ||
DEFAULT_MODEL, | ||
"google:gemini-1.5-flash-latest", | ||
|
@@ -77,7 +75,6 @@ | |
] | ||
export const DEFAULT_SMALL_MODEL = "openai:gpt-4o-mini" | ||
export const DEFAULT_SMALL_MODEL_CANDIDATES = [ | ||
"azure:gpt-4o-mini", | ||
"azure_serverless:gpt-4o-mini", | ||
DEFAULT_SMALL_MODEL, | ||
"google:gemini-1.5-flash-latest", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
system({ title: "Base system prompt" }) | ||
$`- You are concise. | ||
- Answer in markdown. | ||
` | ||
$`- You are concise.` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
system({ title: "Base system prompt" }) | ||
$`## Markdown Output | ||
Respond in Markdown (GitHub Flavored Markdown also supported).` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
system({ title: "Plain text output" }) | ||
$`## Plain Text Output | ||
Respond in plain text. Do not wrap result in Markdown code fences or XML tags. | ||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,9 @@ | |
import { arrayify, logVerbose } from "./util" | ||
import type { | ||
TextContent, | ||
ImageContent, | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The import of
|
||
EmbeddedResource, | ||
} from "@modelcontextprotocol/sdk/types.js" | ||
import { YAMLStringify } from "./yaml" | ||
|
||
export async function startMcpServer( | ||
serverConfig: McpServerConfig, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ | |
// Default systems if no responseType is specified | ||
if (!script.responseType) { | ||
systems.push("system") | ||
systems.push("system.output_markdown") | ||
pelikhan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
systems.push("system.explanations") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The push operation for "system.output_markdown" is unnecessary as it's already included in the default systems.
|
||
systems.push("system.safety_jailbreak") | ||
systems.push("system.safety_harmful_content") | ||
systems.push("system.safety_protected_material") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
script({ | ||
model: "small", | ||
system: ["system", "system.output_plaintext"], | ||
tests: { | ||
keywords: "carrots", | ||
}, | ||
}) | ||
|
||
$`Generate a random recipe with carrots.` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The model name has been changed from "azure:gpt-4o" to "openai:gpt-4o". Ensure that the new model is compatible and available in your environment.