Document-based intelligent dialogue method and device and storage medium

By creating file assistants and conversation threads in ChatGPT, the problem of slow information acquisition after users upload documents is solved, fast intelligent question and answer is realized, time costs are reduced, and information acquisition efficiency is improved.

CN118760754AActive Publication Date: 2024-10-11SHENZHEN MAIFENG TECH CO LTD

Patent Information

Application Number
CN202410918592.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-10-11
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

When users use ChatGPT to analyze document content, the speed of uploading target documents and obtaining answers is slow, resulting in high time costs and affecting the efficiency of information acquisition.

Method used

Realize fast intelligent question and answer by getting the target document and sending it to the large language model, receiving the file ID, using the endpoint to create the associated assistant and conversation thread ID, creating the execution command and sending it to the large language model to generate the response text.

Benefits of technology

By creating file assistants and conversation threads, users can quickly and accurately conduct intelligent Q&A with large language models, significantly reducing time costs and improving information acquisition efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760754A_ABST
    Figure CN118760754A_ABST
Patent Text Reader

Abstract

The invention discloses a document-based intelligent dialogue method and device and a storage medium, and the method comprises the steps: obtaining a target document, sending the target document to a large language model, and receiving a returned file ID; creating an assistant associated with the file ID by using an endpoint, and obtaining a corresponding assistant ID; sending a setting instruction containing the file ID to the large language model, and generating a dialogue thread based on the target document and a corresponding thread ID; when a target question sent by a user is received, creating an execution command containing the target question in the dialogue thread; and sending an instruction for running the dialogue thread to the large language model, so that the large language model runs the execution command and generates a response text. According to the method, the file assistant and the corresponding dialogue thread are created, so that the user can perform efficient and accurate intelligent question and answer with the large language model in the corresponding dialogue thread, and the time cost of the user is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a document-based intelligent dialogue method, device and storage medium. Background Art

[0002] In recent years, with the rapid development of artificial intelligence technology, the document assisted reading function based on artificial intelligence technology has played an important role in helping people quickly obtain information. For example, the ChatGPT-based file reading assistant provided by OpenAI can perform intelligent analysis of document content, thereby helping users quickly extract, locate and summarize information from documents.

[0003] However, when users use ChatGPT to perform content analysis on target documents, the speed of uploading target documents and obtaining answers generated by ChatGPT is often slow, resulting in a high time cost for users to use this function. Summary of the invention

[0004] In order to solve the above technical problems, the present application provides a document-based intelligent dialogue method, device and storage medium.

[0005] The present application embodiment provides a document-based intelligent dialogue method, including:

[0006] Get the target document and send it to the large language model, and receive the document ID in return;

[0007] Use the endpoint to create an assistant associated with the file ID and obtain the corresponding assistant ID;

[0008] Sending a setting instruction including the document ID to the large language model to generate a conversation thread based on the target document and a corresponding thread ID;

[0009] When receiving a target question sent by a user, creating an execution command containing the target question in the conversation thread;

[0010] An instruction to run the dialog thread is sent to the large language model, so that the large language model runs the execution command and generates a response text.

[0011] In some embodiments, when receiving a target question sent by a user, creating an execution command containing the target question in the conversation thread specifically includes:

[0012] Obtain the target question and the corresponding file ID;

[0013] The corresponding thread ID and assistant ID are matched according to the corresponding file ID, and an execution command containing the target question is created in the dialogue thread corresponding to the thread ID.

[0014] In some embodiments, when sending an instruction to run the conversation thread to the large language model, the target question is synchronously delivered using the assistant corresponding to the assistant ID.

[0015] In some embodiments, after sending the instruction to run the conversation thread to the large language model, the method further includes: sending an instruction to request an answer to the large language model; and receiving the response text generated by the large language model.

[0016] In some embodiments, after obtaining the target document, the method further includes: uploading the target document to a cloud storage platform for storage.

[0017] In some embodiments, obtaining the target document includes: receiving the target document uploaded by a user, or receiving a URL uploaded by a user, wherein the URL includes the target document.

[0018] In some embodiments, the target question sent by the user includes an associated question consisting of several sub-questions.

[0019] In some embodiments, when the associated question sent by the user is received, the response text generated by the large language model includes the response content corresponding to each of the sub-questions.

[0020] The present application also provides a document-based intelligent dialogue device, including:

[0021] A creation module is used to obtain a target document and send it to a large language model, and receive a returned file ID; create an assistant associated with the file ID using an endpoint, and obtain a corresponding assistant ID; send a setting instruction containing the file ID to the large language model, and generate a conversation thread based on the target document and a corresponding thread ID;

[0022] The dialogue module is used to create an execution command containing the target question in the dialogue thread when receiving the target question sent by the user; and send an instruction to run the dialogue thread to the large language model so that the large language model runs the execution command and generates a response text.

[0023] In addition, an embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any document-based intelligent dialogue method provided in the embodiment of the present application is implemented.

[0024] Compared with the prior art, the beneficial effects of the embodiments of the present application are:

[0025] The document-based intelligent dialogue method provided by the present application includes obtaining a target document and sending it to a large language model, receiving the returned file ID; using an endpoint to create an assistant associated with the file ID, and obtaining the corresponding assistant ID; sending a setting instruction containing the file ID to the large language model, generating a dialogue thread based on the target document and a corresponding thread ID; when receiving a target question sent by a user, creating an execution command containing the target question in the dialogue thread; sending an instruction to run the dialogue thread to the large language model, so that the large language model runs the execution command and generates a response text. The above method, by creating a file assistant and a dialogue thread, allows users to conduct accurate and fast intelligent question and answer with the large language model in the corresponding dialogue thread after uploading the target document, effectively reducing the user's time cost. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the implementation manner will be briefly introduced below. Obviously, the drawings described below are only some implementation manners of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0027] Figure 1 It is a flowchart of a document-based intelligent dialogue method provided in an embodiment of the present application;

[0028] Figure 2 It is a schematic diagram of the structure of a document-based intelligent dialogue device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0030] It should be understood that the step numbers used in this document are only for convenience of description and are not intended to limit the order in which the steps are executed.

[0031] It should be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0032] The terms “include” and “comprising” indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0033] The term "and / or" means and includes any and all possible combinations of one or more of the associated listed items.

[0034] Since the advent of ChatGPT, the function of using artificial intelligence technology to improve document reading efficiency has attracted much attention from users. Usually, ChatGPT extracts and summarizes information from document content uploaded by users based on a large-scale language model. Users can deeply explore the document structure and content through conversational learning.

[0035] However, when users use ChatGPT, the speed of uploading target documents and obtaining answers generated by ChatGPT is often slow and time-consuming, resulting in low efficiency in users' acquisition of document content information.

[0036] Based on the above technical problems, the present application provides a document-based intelligent dialogue method.

[0037] See also Figure 1 , the intelligent dialogue method comprises the following steps:

[0038] S1: Get the target document and send it to the large language model, and receive the returned document ID.

[0039] S2: Use the endpoint to create an assistant associated with the file ID and obtain the corresponding assistant ID.

[0040] S3: Sending a setting instruction including the document ID to the large language model to generate a conversation thread based on the target document and a corresponding thread ID.

[0041] S4: When a target question sent by a user is received, an execution command including the target question is created in the conversation thread.

[0042] S5: Sending an instruction to run the conversation thread to the large language model, so that the large language model runs the execution command and generates a response text.

[0043] The large language model includes ChatGPT launched by OpenAI. It should be noted that the relevant embodiments of the present application will be explained using ChatGPT as an example, but it does not constitute a limitation on the large language model.

[0044] In this embodiment, the method of obtaining the target document described in step S1 includes receiving a target document uploaded by a user, or receiving a URL uploaded by a user, wherein the URL contains the target document; wherein, when the user uploads the target document via a URL, it is necessary to enter a corresponding page to download the target document.

[0045] It should be noted that after the target document is obtained, it can be uploaded to a cloud storage platform for storage.

[0046] Specifically, the acquired documents can be uploaded to OSS for data storage. At this time, users can obtain the uploaded documents and their corresponding session records by logging into different devices through their accounts, without having to repeatedly obtain relevant data when updating the device.

[0047] In this embodiment, after uploading a document to OSS, a corresponding link will be generated, which can be sent to the front end to download the document again. At the same time, the link will also be sent to ChatGPT.

[0048] For example, you can use the Files / Create endpoint to upload a document. Here are the steps to upload a document using Postman:

[0049] (1) Set the Authorization header to Bearer<MY GPT-4API KEY> ;

[0050] (2) Set the request type to POST;

[0051] (3) Set the request URL to https: / / api.openai.com / v1 / files;

[0052] (4) Set the body to type form-data;

[0053] (5) Create a file key and set the purpose attribute to assistants;

[0054] After uploading the above code and the target document to ChatGPT, you will get the file_ID (i.e. file ID) returned by ChatGPT and record the file ID.

[0055] Step S2 of this embodiment involves assistant creation. Specifically, an assistant can be created using the createAssistant endpoint: specific settings of the assistant are sent to the createAssistant endpoint, including the name, description, model used, type, and file ID to be read, etc. After the creation is complete, the assistant ID returned by the endpoint is obtained and the assistant ID is recorded.

[0056] Step S3 of this embodiment involves creating a conversation thread and allocating an assistant. Specifically, the file ID and user instructions recorded in step S1 are concatenated to obtain a setting instruction, which is then sent to ChatGPT to generate a conversation thread based on the target document content.

[0057] Specifically, the setting instructions include creation instructions, user instructions and file IDs, wherein the user instructions include function instructions corresponding to the question splicing issued by the user.

[0058] Exemplarily, after receiving the target document uploaded by the user, the following code is executed:

[0059] const thread = await openai.beta.threads.create(); / / Create instruction

[0060] {"messages":[

[0061] {"role":"user",

[0062] "content":"Give me a summary based on the document content.?", / / User instructions

[0063] "file_ids":["file-ethprices"] / / File ID

[0064] }]}

[0065] Based on the above code, ChatGPT will return the corresponding thread ID. At this time, all subsequent conversations between ChatGPT and the user will be conducted in the conversation thread corresponding to the thread ID, ensuring that ChatGPT will generate accurate responses based on the target document for subsequent questions raised by the user.

[0066] In this embodiment, steps S4 and S5 involve: when a target question sent by a user is received, an execution command containing the target question is created in the corresponding conversation thread, and an instruction to run the conversation thread is sent to ChatGPT, so that ChatGPT runs the execution command and generates a response text.

[0067] The target question includes a question edited by the user or an instruction selected by the user.

[0068] Exemplarily, the instruction to run the conversation thread may be:

[0069]

[0070] Specifically, after sending an instruction to run the conversation thread to ChatGPT, it is necessary to send an instruction to request an answer again to receive the response text generated by ChatGPT and send the response text to the front end.

[0071] It is understandable that after receiving the response file, the response text can be stored in the database.

[0072] The above-mentioned embodiment of the present application can associate the target document uploaded by the user with the corresponding conversation thread by creating an assistant and a conversation thread. When the user conducts an intelligent conversation with a large language model based on the document, the user can quickly get a response through the corresponding conversation thread, thereby significantly improving the efficiency of obtaining document information and greatly reducing the user's time cost.

[0073] In another embodiment, when a user asks a question through the front end, the question and its corresponding file ID are received, and the corresponding thread ID and assistant ID are matched based on the file ID to create an execution command containing the question in the conversation thread corresponding to the thread ID.

[0074] Exemplarily, the execution command may be:

[0075] from openaiimport OpenAI

[0076] client=OpenAI()

[0077] thread_message=client.beta.threads.messages.create(

[0078] "thread_abc123", / / pass thread ID

[0079] role="user",

[0080] content = "How does AI work? Explain it in simple terms.", / / User question )

[0082] At this time, when the instruction to run the conversation thread is sent to ChatGPT, the assistant corresponding to the assistant ID will also synchronously pass the target question.

[0083] It should be noted that the URL must contain the corresponding thread ID.

[0084] In another embodiment, the target question sent by the user may include an associated question consisting of several sub-questions. When the associated question sent by the user is received, the response text generated by ChatGPT will also include the response content corresponding to each sub-question.

[0085] For example, after receiving the target question sent by the user and splicing it into the following information:

[0086] List three related questions based on what I sent.Specific requirements are as follows.

[0087] The language of the question must match what I sent.

[0088] What I sent is [questions]

[0089] The generated questions must be highly relevant, there is no need to list keywords and summary content.

[0090] Limit each relevant question to 20words or less. Three questions must be generated.

[0091] The instruction to run the conversation thread containing the above information is sent to ChatGPT, so that ChatGPT generates a response text to reply to the above three questions. At this time, the three questions are stored in the database and sent to the front end synchronously, and the user can see a complete set of answers through the front end.

[0092] See also Figure 2 Another embodiment of the present application further provides a document-based intelligent dialogue device, including a creation module 101 and a dialogue module 102.

[0093] The creation module 101 is used to obtain the target document and send it to the large language model, and receive the returned file ID; use the endpoint to create an assistant associated with the file ID and obtain the corresponding assistant ID; send the setting instruction containing the file ID to the large language model, and generate a conversation thread based on the target document and the corresponding thread ID.

[0094] The dialogue module 102 is used to create an execution command containing the target question in the dialogue thread when receiving the target question sent by the user; and send an instruction to run the dialogue thread to the large language model so that the large language model runs the execution command and generates a response text.

[0095] Since the information interaction, execution process, etc. between the modules in the above-mentioned device are based on the same concept as the embodiment of the method of the present application, the specific contents can be found in the description of the embodiment of the method of the present application and will not be repeated here.

[0096] The present application also provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the document-based intelligent dialogue method as described above is implemented.

[0097] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-monitorable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.

[0098] The above is a preferred embodiment of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications are also considered to be within the scope of protection of the present application.

Claims

1. A document-based intelligent dialogue method, characterized in that: include: Get the target document and send it to the large language model, and receive the document ID in return; Use the endpoint to create an assistant associated with the file ID and obtain the corresponding assistant ID; Sending a setting instruction including the document ID to the large language model to generate a conversation thread based on the target document and a corresponding thread ID; When receiving a target question sent by a user, creating an execution command containing the target question in the conversation thread; An instruction to run the dialog thread is sent to the large language model, so that the large language model runs the execution command and generates a response text.

2. The document-based intelligent dialogue method according to claim 1, characterized in that: When receiving the target question sent by the user, creating an execution command containing the target question in the conversation thread, specifically including: Obtain the target question and the corresponding file ID; The corresponding thread ID and assistant ID are matched according to the corresponding file ID, and an execution command containing the target question is created in the dialogue thread corresponding to the thread ID.

3. The document-based intelligent dialogue method according to claim 2, characterized in that: Also includes: When sending an instruction to run the dialogue thread to the large language model, the target question is synchronously delivered using the assistant corresponding to the assistant ID.

4. The document-based intelligent dialogue method according to claim 1, characterized in that: After sending the instruction to run the conversation thread to the large language model, the method further includes: Sending a request for an answer to the large language model; The response text generated by the large language model is received.

5. The document-based intelligent dialogue method according to claim 1, characterized in that: After obtaining the target document, the method further includes: The target document is uploaded to a cloud storage platform for storage.

6. The document-based intelligent dialogue method according to claim 1, characterized in that: The obtaining of the target document comprises: receiving the target document uploaded by the user, or; A URL uploaded by a user is received, wherein the URL includes the target document.

7. The document-based intelligent dialogue method according to claim 1, characterized in that: The target question sent by the user includes an associated question consisting of several sub-questions.

8. The document-based intelligent dialogue method according to claim 7, characterized in that: When the associated question sent by the user is received, the response text generated by the large language model contains the response content corresponding to each of the sub-questions.

9. A document-based intelligent dialogue device, characterized in that: include: Create a module to get the target document and send it to the large language model, and receive the document ID in return; Using the endpoint to create an assistant associated with the document ID and obtain the corresponding assistant ID; sending a setting instruction containing the document ID to the large language model to generate a conversation thread based on the target document and a corresponding thread ID; A dialogue module, configured to, when receiving a target question sent by a user, create an execution command containing the target question in the dialogue thread; An instruction to run the dialog thread is sent to the large language model, so that the large language model runs the execution command and generates a response text.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the document-based intelligent dialogue method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Automatic conversation techniques

    CN102067167A

  • Extension to the expert conversation builder

    CN104321765A

  • Extraction type machine intelligent reading understanding question-answering system

    CN111611361A

  • Railway industry intelligent question and answer assistant system

    CN117633179A

  • AI service system and device based on large language model

    CN118260458A

Cited By

  • Intelligent interaction method and system of document

    CN119645268A