0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

背景

openai.demo の Front-Back でのやりとりが新しくなっていたのでそのメモ

概要

以下、サンプルにおける、response の新旧比較

旧側は、日本語サンプルである以下を基準とした。

比較

backend

backend 側にテストが用意されているので、その辺りを確認するのが手っ取り早い

ちなみに、正常時の応答の一例が以下

response sample
{
    "context": {
        "data_points": {
            "text": [
                "Benefit_Options-2.pdf: There is a whistleblower policy."
            ]
        },
        "thoughts": [
            {
                "description": "What is the capital of France?",
                "props": {
                    "filter": null,
                    "top": 3,
                    "use_semantic_captions": false,
                    "use_semantic_ranker": false,
                    "use_text_search": true,
                    "use_vector_search": true
                },
                "title": "Search using user query"
            },
            {
                "description": [
                    {
                        "captions": [
                            {
                                "additional_properties": {},
                                "highlights": [],
                                "text": "Caption: A whistleblower policy."
                            }
                        ],
                        "category": null,
                        "content": "There is a whistleblower policy.",
                        "embedding": null,
                        "groups": null,
                        "id": "file-Benefit_Options_pdf-42656E656669745F4F7074696F6E732E706466-page-2",
                        "imageEmbedding": null,
                        "oids": null,
                        "reranker_score": 3.4577205181121826,
                        "score": 0.03279569745063782,
                        "sourcefile": "Benefit_Options.pdf",
                        "sourcepage": "Benefit_Options-2.pdf"
                    }
                ],
                "props": null,
                "title": "Search results"
            },
            {
                "description": [
                    "{'role': 'system', 'content': \"You are an intelligent assistant helping Contoso Inc employees with their healthcare plan questions and employee handbook questions. Use 'you' to refer to the individual asking the questions even if they ask with 'I'. Answer the following question using only the data provided in the sources below. For tabular information return it as an html table. Do not return markdown format. Each source has a name followed by colon and the actual information, always include the source name for each fact you use in the response. If you cannot answer using the sources below, say you don't know. Use below example to answer\"}",
                    "{'role': 'user', 'content': \"\\n'What is the deductible for the employee plan for a visit to Overlake in Bellevue?'\\n\\nSources:\\ninfo1.txt: deductibles depend on whether you are in-network or out-of-network. In-network deductibles are $500 for employee and $1000 for family. Out-of-network deductibles are $1000 for employee and $2000 for family.\\ninfo2.pdf: Overlake is in-network for the employee plan.\\ninfo3.pdf: Overlake is the name of the area that includes a park and ride near Bellevue.\\ninfo4.pdf: In-network institutions include Overlake, Swedish and others in the region\\n\"}",
                    "{'role': 'assistant', 'content': 'In-network deductibles are $500 for employee and $1000 for family [info1.txt] and Overlake is in-network for the employee plan [info2.pdf][info4.pdf].'}",
                    "{'role': 'user', 'content': 'What is the capital of France?\\nSources:\\n Benefit_Options-2.pdf: There is a whistleblower policy.'}"
                ],
                "props": {
                    "model": "gpt-35-turbo"
                },
                "title": "Prompt to generate answer"
            }
        ]
    },
    "message": {
        "content": "The capital of France is Paris. [Benefit_Options-2.pdf].",
        "function_call": null,
        "role": "assistant",
        "tool_calls": null
    },
    "session_state": null
}

frontend

front 側の定義は、以下を見るのが良い

backend

この時期のサンプルには test が用意されていなかった為、日本語版デモでも tests が無い。
その為、新のように、result.json は無いので、実際の応答生成部分を見るしかない

とはいえ、この頃は simple なので特に困らない

応答例
return {
    "data_points": results,
    "answer": response_text, 
    "thoughts": f"Searched for:<br>{query_text}<br><br>Conversations:<br>" + msg_to_display.replace('\n', '<br>')
    }

front

新と同様に、models.ts を確認すればよく、ここで比較してみるのも良い

あとがき

以下の影響で差分が大きくなってるのが困るところ

  • Stream 対応による、"delta"
  • ThoughtStep() による、"thoughts" の視覚強化。まぁ、ここは無視でも :sweat:
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?