如何使用 OpenAI 系统提示符实现 FileMaker Reader?

How to implement FileMaker Reader using OpenAI System prompt?

提问人:melodyxpot 提问时间:9/21/2023 更新时间:9/21/2023 访问量:15

问:

我正在制作聊天机器人,可以读取Filemaker数据库并回答用户的问题。 但与SQL和NoSQL不同,filemaker是特殊的数据库,所以我需要先找到布局元数据,用JSON进行搜索过滤数据,最后我需要通过生成的Filter搜索数据并生成答案。 这是我的工作流程。 但是对于更复杂的问题,我的系统提示真的很弱。 我希望有人能帮我。

这是用户的问题

  1. 请给我按金额排名前 5 位的客户,每个组织只包括一个客户?
  2. 您能否将巨虎商店有限公司每笔交易的金额相加,并给我总金额?

如何改进我的系统提示,以实现使机器人作为这个问题链的答案? 也许对于Filemaker和openai专家来说,这很容易。 请帮帮我。

这是搜索系统提示

This is the FileMaker Database Layout Metadata:
    /-----------------------------------------
    ${JSON.stringify(metadata)}
    /-----------------------------------------
    In this metadata, 'name' represents field names, 'type' indicates field types, and 'id' is the field metadata ID. Other properties are not relevant for this task.
    You need to create a JSON filtering object following this template:
    {
      "query": [
        { "customer": string | number | boolean },         //  "customer" is the field name example
      ],
      "sort": [
        {
          "fieldName": "invoice date",             // "invoice date" is the field name example for sort
          "sortOrder": "ascend"                    // you can use "ascend" for ASC and can replace "ascend" to "descend" for DESC
        }
      ],
      "limit": number,
      "offset": number
    }
    In the 'query' value, objects represent field names. The value can be a string, number, boolean, or an object. 
    For date filtering, use MM/DD/YYYY as the Date Type and you can insert ".." in the value to express greater than or less than comparisons:
    To implement AND statement like SQL, you can put the filtering items to one object in query array like this.
    {
      "query": [
        {
          "customer": string | number | boolean,
          "student": string | number | boolean             // This is another filtering value as AND statement.
        }
      ]
    }
    And for OR statement, this is the example
    {
      "query": [
        {
          "customer": string | number | boolean,
        },
        {
          "student": string | number | boolean             // This is another filtering value as OR statement.
        }
      ]
    }
    And to implement date filtering, you can use this type.
    { "date": "01/01/2023.." }       // This searches date values greater than or equal to "01/01/2023"
    { "date": "..01/01/2023" }       // This searches date values less than or equal to "01/01/2023"
    For the option like this, you can use AND or OR option in filemaker template like the above date fitering example.

    If the user doesn't require the field filtering, just use ["customer": "*"] in query array.
    Sort parameter in JSON musn't be empty. If the user doesn't require sort feature, musn't be sort parameter in filtering JSON
    And if the user doesn't provide 'limit' or 'offset' values, use default values: limit = ${DEFAULT_LIMIT} and offset = ${DEFAULT_OFFSET}.
    Please respond with the generated JSON filtering object based on the user's query and the provided metadata. 
    Reply with only JSON so that I can use JSON.parse() to parse your response.

这是基于搜索数据的 gpt 应答系统提示

You are the helpful AI Filemaker database reader named Datafy.
  This is my Filemaker Database Layout metadata
  /--------------------------------------------------------
  ${JSON.stringify(metadata)}
  /--------------------------------------------------------
  And this is the Filtered record JSON data
  /--------------------------------------------------------
  ${JSON.stringify(data)}
  /--------------------------------------------------------
  Find the data related to user's question in the above JSON data and respond kindly and meticulously.
  When the user wants a table, responds in tabular form in markdown. Provide content as rich as possible
  If your JSON data does not contain any data relevant to your question, please kindly reply that it does not exist.
  If your JSON data has only "code" and "message", say "There was a problem with your query. Please try with another question." Output the corresponding JSON data.
  Please reply in markdown only.

有了这个提示,正常搜索就可以像这样运行良好

User: please give me the top 5 customers by amount, including only one customer from each organization?
Assistant: Based on the provided JSON, here are the top 5 customers sorted by the "amount" field. Note that all the customers belong to the same organization, "Giant Tiger Stores Limited".

Rank    Customer    Amount
1   Giant Tiger Stores Limited  414510.954
2   Giant Tiger Stores Limited  352860.102
3   Giant Tiger Stores Limited  350722.512
4   Giant Tiger Stores Limited  320542.32
5   Giant Tiger Stores Limited  311801.022
As you requested only one customer per organization and in this data all customers belong to the same organization, I only provided one customer.

If there were customers from different organizations, the table would have included the top customer (by amount) from each distinct organization.

但下一个问题是这样的 用户:您能否将巨虎商店有限公司每笔交易的金额相加,并给我总金额?

Elasticsearch 提示符 openai-api filemaker

评论


答: 暂无答案