From 1989e7d4c210ac16798b924646985ac5fda51992 Mon Sep 17 00:00:00 2001 From: Jason Gill Date: Thu, 2 Mar 2023 10:39:57 -0500 Subject: [PATCH] Update examples to prevent confusing missing _type warning (#1391) The YAML and JSON examples of prompt serialization now give a strange `No '_type' key found, defaulting to 'prompt'` message when you try to run them yourself or copy the format of the files. The reason for this harmless warning is that the _type key was not in the config files, which means they are parsed as a standard prompt. This could be confusing to new users (like it was confusing to me after upgrading from 0.0.85 to 0.0.86+ for my few_shot prompts that needed a _type added to the example_prompt config), so this update includes the _type key just for clarity. Obviously this is not critical as the warning is harmless, but it could be confusing to track down or be interpreted as an error by a new user, so this update should resolve that. --- docs/modules/prompts/examples/example_prompt.json | 1 + docs/modules/prompts/examples/few_shot_prompt.json | 1 + docs/modules/prompts/examples/few_shot_prompt.yaml | 1 + .../prompts/examples/few_shot_prompt_examples_in.json | 1 + .../examples/few_shot_prompt_yaml_examples.yaml | 1 + .../prompts/examples/prompt_serialization.ipynb | 10 +++++++++- docs/modules/prompts/examples/simple_prompt.json | 1 + docs/modules/prompts/examples/simple_prompt.yaml | 1 + .../examples/simple_prompt_with_template_file.json | 1 + 9 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/modules/prompts/examples/example_prompt.json b/docs/modules/prompts/examples/example_prompt.json index 05098c4aac..9942d613ed 100644 --- a/docs/modules/prompts/examples/example_prompt.json +++ b/docs/modules/prompts/examples/example_prompt.json @@ -1,4 +1,5 @@ { + "_type": "prompt", "input_variables": ["input", "output"], "template": "Input: {input}\nOutput: {output}" } diff --git a/docs/modules/prompts/examples/few_shot_prompt.json b/docs/modules/prompts/examples/few_shot_prompt.json index b6ed30ad0f..118c094fd9 100644 --- a/docs/modules/prompts/examples/few_shot_prompt.json +++ b/docs/modules/prompts/examples/few_shot_prompt.json @@ -3,6 +3,7 @@ "input_variables": ["adjective"], "prefix": "Write antonyms for the following words.", "example_prompt": { + "_type": "prompt", "input_variables": ["input", "output"], "template": "Input: {input}\nOutput: {output}" }, diff --git a/docs/modules/prompts/examples/few_shot_prompt.yaml b/docs/modules/prompts/examples/few_shot_prompt.yaml index b42d494f33..b08cb3a962 100644 --- a/docs/modules/prompts/examples/few_shot_prompt.yaml +++ b/docs/modules/prompts/examples/few_shot_prompt.yaml @@ -4,6 +4,7 @@ input_variables: prefix: Write antonyms for the following words. example_prompt: + _type: prompt input_variables: ["input", "output"] template: diff --git a/docs/modules/prompts/examples/few_shot_prompt_examples_in.json b/docs/modules/prompts/examples/few_shot_prompt_examples_in.json index 8b95f63c31..e3f9788e97 100644 --- a/docs/modules/prompts/examples/few_shot_prompt_examples_in.json +++ b/docs/modules/prompts/examples/few_shot_prompt_examples_in.json @@ -3,6 +3,7 @@ "input_variables": ["adjective"], "prefix": "Write antonyms for the following words.", "example_prompt": { + "_type": "prompt", "input_variables": ["input", "output"], "template": "Input: {input}\nOutput: {output}" }, diff --git a/docs/modules/prompts/examples/few_shot_prompt_yaml_examples.yaml b/docs/modules/prompts/examples/few_shot_prompt_yaml_examples.yaml index 438054c1d4..250ca775f4 100644 --- a/docs/modules/prompts/examples/few_shot_prompt_yaml_examples.yaml +++ b/docs/modules/prompts/examples/few_shot_prompt_yaml_examples.yaml @@ -4,6 +4,7 @@ input_variables: prefix: Write antonyms for the following words. example_prompt: + _type: prompt input_variables: ["input", "output"] template: diff --git a/docs/modules/prompts/examples/prompt_serialization.ipynb b/docs/modules/prompts/examples/prompt_serialization.ipynb index 8b85121e03..2e4ff89f1b 100644 --- a/docs/modules/prompts/examples/prompt_serialization.ipynb +++ b/docs/modules/prompts/examples/prompt_serialization.ipynb @@ -58,6 +58,7 @@ "name": "stdout", "output_type": "stream", "text": [ + "_type: prompt\r\n", "input_variables:\r\n", " [\"adjective\", \"content\"]\r\n", "template: \r\n", @@ -108,6 +109,7 @@ "output_type": "stream", "text": [ "{\r\n", + " \"_type\": \"prompt\",\r\n", " \"input_variables\": [\"adjective\", \"content\"],\r\n", " \"template\": \"Tell me a {adjective} joke about {content}.\"\r\n", "}\r\n" @@ -156,6 +158,7 @@ "output_type": "stream", "text": [ "{\r\n", + " \"_type\": \"prompt\",\r\n", " \"input_variables\": [\"adjective\", \"content\"],\r\n", " \"template_path\": \"simple_template.txt\"\r\n", "}\r\n" @@ -279,6 +282,7 @@ "prefix: \r\n", " Write antonyms for the following words.\r\n", "example_prompt:\r\n", + " _type: prompt\r\n", " input_variables:\r\n", " [\"input\", \"output\"]\r\n", " template:\r\n", @@ -346,6 +350,7 @@ "prefix: \r\n", " Write antonyms for the following words.\r\n", "example_prompt:\r\n", + " _type: prompt\r\n", " input_variables:\r\n", " [\"input\", \"output\"]\r\n", " template:\r\n", @@ -413,6 +418,7 @@ " \"input_variables\": [\"adjective\"],\r\n", " \"prefix\": \"Write antonyms for the following words.\",\r\n", " \"example_prompt\": {\r\n", + " \"_type\": \"prompt\",\r\n", " \"input_variables\": [\"input\", \"output\"],\r\n", " \"template\": \"Input: {input}\\nOutput: {output}\"\r\n", " },\r\n", @@ -478,6 +484,7 @@ " \"input_variables\": [\"adjective\"],\r\n", " \"prefix\": \"Write antonyms for the following words.\",\r\n", " \"example_prompt\": {\r\n", + " \"_type\": \"prompt\",\r\n", " \"input_variables\": [\"input\", \"output\"],\r\n", " \"template\": \"Input: {input}\\nOutput: {output}\"\r\n", " },\r\n", @@ -542,6 +549,7 @@ "output_type": "stream", "text": [ "{\r\n", + " \"_type\": \"prompt\",\r\n", " \"input_variables\": [\"input\", \"output\"],\r\n", " \"template\": \"Input: {input}\\nOutput: {output}\" \r\n", "}\r\n" @@ -622,7 +630,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.9" + "version": "3.11.2" }, "vscode": { "interpreter": { diff --git a/docs/modules/prompts/examples/simple_prompt.json b/docs/modules/prompts/examples/simple_prompt.json index 05a3731aed..c97a96e743 100644 --- a/docs/modules/prompts/examples/simple_prompt.json +++ b/docs/modules/prompts/examples/simple_prompt.json @@ -1,4 +1,5 @@ { + "_type": "prompt", "input_variables": ["adjective", "content"], "template": "Tell me a {adjective} joke about {content}." } diff --git a/docs/modules/prompts/examples/simple_prompt.yaml b/docs/modules/prompts/examples/simple_prompt.yaml index 4642b08d7c..5377b92f20 100644 --- a/docs/modules/prompts/examples/simple_prompt.yaml +++ b/docs/modules/prompts/examples/simple_prompt.yaml @@ -1,3 +1,4 @@ +_type: prompt input_variables: ["adjective", "content"] template: diff --git a/docs/modules/prompts/examples/simple_prompt_with_template_file.json b/docs/modules/prompts/examples/simple_prompt_with_template_file.json index d3acffe3c2..365b0fd65f 100644 --- a/docs/modules/prompts/examples/simple_prompt_with_template_file.json +++ b/docs/modules/prompts/examples/simple_prompt_with_template_file.json @@ -1,4 +1,5 @@ { + "_type": "prompt", "input_variables": ["adjective", "content"], "template_path": "simple_template.txt" }