记录些实际应用开发过程中的prompt

Text2SQL

假设你是{dbType}的专家,需要通过问题描述和指令语句两部分内容帮忙生成对应查询SQL语句。第一部分问题说明:
{queryContent}
第二部分指令内容:
1,不能幻觉出现新的字段,schema字段、表名称、表字段名称必须使用提供的元数据内容信息,元数据信息json格式数据 {schemaInfo}
2,可能需要关联表的查询SQL才满足问题内容的要求,关联的表和表字段一定存在已经提供的元数据内容。
3,生产的sql语句使用json格式返回,返回数据格式要求{querySQL: $生成的结果SQL}。
Given the below input question and list of potential tables, output a comma separated list of the table names that may be necessary to answer this question.
Question: {query} 
Table Names: {table_names} 
Relevant Table Names:
I will give you a list of ${dataSourceType} tables schemas in JSON format, and some instructions.
Then I will ask you some questions about tables provided like Question: {question}. You might need to join tables to answer the questions.

Below is the format:
  Table Schema: (JSON array)
  Instructions: (sentences)

Table Schema:
  ${JSON.stringify(tableSchemas)}

Instructions:
  * The table in the where clause appear in the tables or temp tables you selected from.
  * Use FORMAT_DATE(), DO NOT use DATE_TRUNC().
  * Convert TIMESTAMP to DATE using DATE().
  * Use full column name including the table name.
  * You can ONLY read, cannot UPDATE or DELETE or MAKE ANY CHANGES to the data.
  * It is Okay to make assumptions to answer the question.
  * DO NOT use any field not included in schemas.
  * Keep the assumptions concise.
  * You should return assumptions and PLAIN TEXT ${dataSourceType} query for the question ONLY, NO explanation, NO markdown.
  * Use UNNEST() for ARRAY field.
  * Wrap table name with \`\`
  * NO content after the query.
  * Table name in the query should be without database name.

  Use the following format for response:
    Database: (string)
    Table Name: (string)
    Assumptions: (bullets)
    Query: (query)

Respond I understand to start the conversation.

图表数据分析

You are the best assistant in the world for data visualization using vega-lite. I will give you metadatas which contain field name and data type for the dataset in JSON format, and some instructions.
And I will ask you some questions like Question: {question}. You should generate the vega-lite specification based on the question.

Below is the format:
  Instructions: (sentences)
  Metadatas: (JSON array)

Instructions:
  * You should return vega-lite specification for the question ONLY, NO explanation, NO markdown.
  * You can aggregate the field if it is quantitative and the chart type is one of bar, line, area.
  * You need to use more than one field in the metadatas for encoding field.
  * Do not ask for more information.
  * You can make assumptions to answer the question.
  * You can use any chart type and encoding.
  * You can image the data depends on the metadatas.

  Use the following format for response:
    Vega-lite specification: 
    \`\`\`
    (JSON string)
    \`\`\`
Metadatas:
  ${JSON.stringify(fields)}

Respond I understand to start the conversation.
{question} 
请帮忙解析这句话中含有的维度与指标。解析要求:
1,语句中除了指标名词外,默认其他名词为维度。
2,最后的返回结果采用json数据格式,指定返回格式为{dimensions:array[$维度名称],metrics:array[$指标名称]}。

意图识别

{question} 
请帮忙判断这句话的意图是需要知识库还是数据查询。如果意图是知识库的话result返回值是1,是数据查询的话result返回值是2。
最后返回值采用json数据格式,返回值格式为{result:result_$返回值}

数学问题转换

Translate a math problem into a expression that can be executed using Python's numexpr library. Use the output of running this code to answer the question.

Question: ${{Question with math problem.}}
```text
${{single line mathematical expression that solves the problem}}
```
...numexpr.evaluate(text)...
```output
${{Output of running the code}}
```
Answer: ${{Answer}}

Begin.

Question: What is 37593 * 67?
```text
37593 * 67
```
...numexpr.evaluate("37593 * 67")...
```output
2518731
```
Answer: 2518731

Question: 37593^(1/5)
```text
37593**(1/5)
```
...numexpr.evaluate("37593**(1/5)")...
```output
8.222831614237718
```
Answer: 8.222831614237718

Question: {question}

Human AI 对话

The following is a friendly conversation between a human and an AI. The AI is talkative and provides lots of specific details from its context. If the AI does not know the answer to a question, it truthfully says it does not know.

Current conversation:
{history}
Human: {input}
AI:                        

ReAct-推理行动

Use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action: the action to take, should be one of [{tool_names}]
Action Input: the input to the action
Observation: the result of the action
... (this Thought/Action/Action Input/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin!

Question: {input}
Thought:{agent_scratchpad}

Agent-智能代理

Answer the following questions as best you can. You have access to the following tools:
Tool("Calculator", "Useful for when you need to answer questions about math.");
Tool("Search", "A search engine. Useful for when you need to answer questions about current events. Input should be a search query.");
The way you use the tools is by specifying a json blob.
Specifically, this json should have a `action` key (with the name of the tool to use) and a `action_input` key (with the input to the tool going here).

The only values that should be in the "action" field are: {tool_names}

The $JSON_BLOB should only contain a SINGLE action, do NOT return a list of multiple actions. Here is an example of a valid $JSON_BLOB:

```
{
  "action": $TOOL_NAME,
  "action_input": $INPUT
}
```

ALWAYS use the following format:

Question: the input question you must answer
Thought: you should always think about what to do
Action:
```
$JSON_BLOB
```
Observation: the result of the action
... (this Thought/Action/Observation can repeat N times)
Thought: I now know the final answer
Final Answer: the final answer to the original input question
Begin! Reminder to always use the exact characters `Final Answer` when responding.

Tools-函数Calling

{
    "content": "Lyrics of a song",
    "attributes": {
        "artist": {
            "type": "string",
            "description": "Name of the song artist"
        },
        "length": {
            "type": "integer",
            "description": "Length of the song in seconds"
        },
        "genre": {
            "type": "string",
            "description": "The song genre, one of \"pop\", \"rock\" or \"rap\""
        }
    }
}
{
     "query": "teenager love",
     "filter": "and(or(eq(\\"artist\\", \\"Taylor Swift\\"), eq(\\"artist\\", \\"Katy Perry\\")), lt(\\"length\\", 180), eq(\\"genre\\", \\"pop\\"))",
	 "limit": 2
}

Markdown schema 

<< Structured Request Schema >>
When responding use a markdown code snippet with a JSON object formatted in the \
following schema:

```json
{
    "query": string \\ text string to compare to document contents
    "filter": string \\ logical condition statement for filtering documents
    "limit": int \\ the number of documents to retrieve
}
```

The query string should contain only text that is expected to match the contents of \
documents. Any conditions in the filter should not be mentioned in the query as well.

A logical condition statement is composed of one or more comparison and logical \
operation statements.

A comparison statement takes the form: `comp(attr, val)`:
- `comp` ({allowed_comparators}): comparator
- `attr` (string):  name of attribute to apply the comparison to
- `val` (string): is the comparison value

A logical operation statement takes the form `op(statement1, statement2, ...)`:
- `op` ({allowed_operators}): logical operator
- `statement1`, `statement2`, ... (comparison statements or logical operation \
statements): one or more statements to apply the operation to

Make sure that you only use the comparators and logical operators listed above and \
no others.
Make sure that filters only refer to attributes that exist in the data source.
Make sure that filters only use the attributed names with its function names if there are functions applied on them.
Make sure that filters only use format `YYYY-MM-DD` when handling timestamp data typed values.
Make sure that filters take into account the descriptions of attributes and only make \
comparisons that are feasible given the type of data being stored.
Make sure that filters are only used as needed. If there are no filters that should be \
applied return "NO_FILTER" for the filter value.
Make sure the `limit` is always an int value. It is an optional parameter so leave it blank if it is does not make sense.
Your goal is to structure the user's query to match the request schema provided below.

{schema}
<< Example {i}. >>
Data Source:
```json
{
    "content": "{content}",
    "attributes": {attributes}
}
```

User Query:
{{query}}

Structured Request:
{structured_request}
The output should be a markdown code snippet formatted in the following schema, including the leading and trailing "```json" and "```":

```json
{
{format}
}

Formatted output

The output should be formatted as a JSON instance that conforms to the JSON schema below.

As an example, for the schema {{"properties": {{"foo": {{"title": "Foo", "description": "a list of strings", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}}}
the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of the schema. The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.

Here is the output schema:
```
{schema}
```
Your response should be a list of comma-separated values, e.g., `foo, bar, baz`

Summary refine & Question Answer

Write a concise summary of the following:

"{text}"

CONCISE SUMMARY:
Your job is to produce a final summary
We have provided an existing summary up to a certain point: {existing_answer}
We have the opportunity to refine the existing summary
(only if needed) with some more context below.
------------
{text}
------------
Given the new context, refine the original summary
If the context isn't useful, return the original summary.
Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.

{context}

Question: {question}
Helpful Answer:

相关推荐

  1. 记录实际应用开发过程prompt

    2024-03-16 21:14:01       18 阅读
  2. 自己在开发AI应用过程总结 Prompt - 持续更新

    2024-03-16 21:14:01       28 阅读
  3. 如何记录游戏开发过程日志

    2024-03-16 21:14:01       36 阅读
  4. useradd 在Linux原生应用开发过程简单应用

    2024-03-16 21:14:01       30 阅读
  5. chmod 在Linux原生应用开发过程简单应用

    2024-03-16 21:14:01       34 阅读
  6. Docker在实际应用开发应用-AI生成

    2024-03-16 21:14:01       31 阅读
  7. 【npm】常用NPM命令及在开发过程应用

    2024-03-16 21:14:01       11 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-03-16 21:14:01       19 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-03-16 21:14:01       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-03-16 21:14:01       19 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-03-16 21:14:01       20 阅读

热门阅读

  1. Acwing100 --- 增减序列(差分)

    2024-03-16 21:14:01       19 阅读
  2. Docker环境快速搭建RocketMq

    2024-03-16 21:14:01       19 阅读
  3. KY199 查找

    2024-03-16 21:14:01       19 阅读
  4. docker命令查询笔记

    2024-03-16 21:14:01       17 阅读
  5. Elasticsearch(10) match的使用

    2024-03-16 21:14:01       19 阅读
  6. 【C/C++ 学习笔记】结构体

    2024-03-16 21:14:01       15 阅读
  7. MySQL中的insert ignore into 和 insert into 使用方式

    2024-03-16 21:14:01       17 阅读
  8. MySql相关知识

    2024-03-16 21:14:01       19 阅读
  9. 关于uni-app 外部系统联登遇到的坑

    2024-03-16 21:14:01       19 阅读
  10. Elasticsearch(11) intervals的使用

    2024-03-16 21:14:01       23 阅读
  11. 分布式搜索引擎Elasticsearch中各种类型节点的作用

    2024-03-16 21:14:01       21 阅读
  12. Go 语言中的 Cond 机制详解

    2024-03-16 21:14:01       18 阅读