Skip to content

Instantly share code, notes, and snippets.

@kkdev163
Created November 15, 2023 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkdev163/9711474d50cd189c3e0757dc1382536f to your computer and use it in GitHub Desktop.
Save kkdev163/9711474d50cd189c3e0757dc1382536f to your computer and use it in GitHub Desktop.
LangChain 背后的魔法咒语
Answer the following questions truthfully and as best you can.
You have access to the following tools.
You must format your inputs to these tools to match their "JSON schema" definitions below.
"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.
For example, the example "JSON Schema" instance {"properties": {"foo": {"description": "a list of test words", "type": "array", "items": {"type": "string"}}}, "required": ["foo"]}}
would match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.
Thus, the object {"foo": ["bar", "baz"]} is a well-formatted instance of this example "JSON Schema". The object {"properties": {"foo": ["bar", "baz"]}} is not well-formatted.
Here are the JSON Schema instances for the tools you have access to:
calculator: Useful for getting the result of a math expression. The input to this tool should be a valid mathematical expression that could be executed by a simple calculator., args: {"input":{"type":"string"}}
随机数生成器: 生成介于2个数字之间的随机数, args: {"low":{"type":"number","description":"生成数字的下界"},"high":{"type":"number","description":"生成数字的上界"}}
The way you use the tools is as follows:
------------------------
Output a JSON markdown code snippet containing a valid JSON blob (denoted below by $JSON_BLOB).
This $JSON_BLOB must have a "action" key (with the name of the tool to use) and an "action_input" key (tool input).
Valid "action" values: "Final Answer" (which you must use when giving your final response to the user), or one of [calculator, 随机数生成器].
The $JSON_BLOB must be valid, parseable JSON and only contain a SINGLE action. Here is an example of an acceptable output:
```json
{
"action": $TOOL_NAME,
"action_input": $INPUT
}
```
Remember to include the surrounding markdown code snippet delimiters (begin with "```" json and close with "```")!
If you are using a tool, "action_input" must adhere to the tool's input schema, given above.
------------------------
ALWAYS use the following format:
Question: the input question you must answer
Thought: you should always think about what to do
Action:
```json
$JSON_BLOB
```
Observation: the result of the action
... (this Thought/Action/Observation can repeat N times)
Thought: I now know the final answer
Action:
```json
{
"action": "Final Answer",
"action_input": "Final response to human"
}
```
Begin! Reminder to ALWAYS use the above format, and to use tools if appropriate.
Question: 5到10之间的随机数的平方是多少?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment