NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

[Feature Request] 能否加入通过插件分析PDF的功能

Open Why-SVIP opened this issue 1 year ago • 11 comments

🥰 Feature Description

加入通过插件分析PDF的功能

🧐 Proposed Solution

用过插件形式

📝 Additional Information

No response

Why-SVIP avatar Sep 08 '24 06:09 Why-SVIP

Bot detected the issue body's language is not English, translate it automatically.


Title: [Feature Request] Is it possible to add the function of analyzing PDF through plug-in?

Issues-translate-bot avatar Sep 08 '24 06:09 Issues-translate-bot

这个应该也可以通过包装fastgpt的api实现(这里是接口文档地址): https://doc.tryfastgpt.ai/docs/development/openapi/dataset/#%e6%95%b0%e6%8d%ae

实现逻辑

  1. 更新https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/fastgpt 这里的schema,增加创建知识库,以及创建外部文件库集合的api
  2. 编辑mask,增加context内容:告诉LLM,当收到一个(或者多个)PDF的链接的时候,先创建知识库,并将PDF作为集合导入到知识库,并记住知识库的datasetId
  3. 用户提问的时候,尝试调用fastgpt的搜索测试接口查询相关内容。再由大模型总结回答。

lloydzhou avatar Sep 09 '24 03:09 lloydzhou

Bot detected the issue body's language is not English, translate it automatically.


This should also be achieved by wrapping the fastgpt API (here is the interface document address): https://doc.tryfastgpt.ai/docs/development/openapi/dataset/#%e6%95%b0%e6%8d%ae

Implement logic

  1. Update the schema here at https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/fastgpt, and add the API to create a knowledge base and create an external file library collection.
  2. Edit the mask and add context content: Tell LLM that when receiving a link to one (or multiple) PDFs, first create a knowledge base, import the PDF as a collection into the knowledge base, and remember the datasetId of the knowledge base.
  3. When the user asks a question, try to call fastgpt’s search test interface to query related content. Then the large model summarizes the answer.

Issues-translate-bot avatar Sep 09 '24 03:09 Issues-translate-bot

#5384 如果后续实现了plugin runtime支持上传文件的化,前面提到的创建集合这一步可以使用创建一个文件集合 这个API

lloydzhou avatar Sep 09 '24 03:09 lloydzhou

Bot detected the issue body's language is not English, translate it automatically.


#5384 If the plugin runtime is later implemented to support uploading files, the previously mentioned step of creating a collection can be used Create a file collection This API

Issues-translate-bot avatar Sep 09 '24 03:09 Issues-translate-bot

这个应该也可以通过包装fastgpt的api实现(这里是接口文档地址): https://doc.tryfastgpt.ai/docs/development/openapi/dataset/#%e6%95%b0%e6%8d%ae

实现逻辑

  1. 更新https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/fastgpt 这里的schema,增加创建知识库,以及创建外部文件库集合的api
  2. 编辑mask,增加context内容:告诉LLM,当收到一个(或者多个)PDF的链接的时候,先创建知识库,并将PDF作为集合导入到知识库,并记住知识库的datasetId
  3. 用户提问的时候,尝试调用fastgpt的搜索测试接口查询相关内容。再由大模型总结回答。

好的,感谢,我研究一下

Why-SVIP avatar Sep 09 '24 04:09 Why-SVIP

Bot detected the issue body's language is not English, translate it automatically.


This should also be achieved by wrapping the fastgpt API (here is the interface document address): https://doc.tryfastgpt.ai/docs/development/openapi/dataset/#%e6%95%b0%e6%8d%ae

Implement logic

  1. Update the schema here at https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/fastgpt, and add the API to create a knowledge base and create an external file library collection
  2. Edit the mask and add context content: tell LLM that when receiving a link to one (or more) PDFs, first create a knowledge base, import the PDFs as a collection into the knowledge base, and remember the datasetId of the knowledge base.
  3. When the user asks a question, try to call fastgpt's search test interface to query related content. Then the large model summarizes the answer.

Okay, thanks, I'll look into it

Issues-translate-bot avatar Sep 09 '24 04:09 Issues-translate-bot

这个应该也可以通过包装fastgpt的api实现(这里是接口文档地址): https://doc.tryfastgpt.ai/docs/development/openapi/dataset/#%e6%95%b0%e6%8d%ae

实现逻辑

  1. 更新https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/fastgpt 这里的schema,增加创建知识库,以及创建外部文件库集合的api
  2. 编辑mask,增加context内容:告诉LLM,当收到一个(或者多个)PDF的链接的时候,先创建知识库,并将PDF作为集合导入到知识库,并记住知识库的datasetId
  3. 用户提问的时候,尝试调用fastgpt的搜索测试接口查询相关内容。再由大模型总结回答。

Vaviera avatar Sep 09 '24 04:09 Vaviera

Bot detected the issue body's language is not English, translate it automatically.


This should also be achieved by wrapping the fastgpt API (here is the interface document address): https://doc.tryfastgpt.ai/docs/development/openapi/dataset/#%e6%95%b0%e6%8d%ae

Implement logic

  1. Update the schema here at https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/fastgpt, and add the API to create a knowledge base and create an external file library collection
  2. Edit the mask and add context content: tell LLM that when receiving a link to one (or more) PDFs, first create a knowledge base, import the PDFs as a collection into the knowledge base, and remember the datasetId of the knowledge base.
  3. When the user asks a question, try to call fastgpt's search test interface to query related content. Then the large model summarizes the answer.

Issues-translate-bot avatar Sep 09 '24 04:09 Issues-translate-bot

https://chatgpt.com/g/g-V2KIUZSj0-pdf-ai-pdf

这里有一个由myaidrive.com提供的使用人数比较多的GPTs,名字叫做PDF AI PDF,这一个GPTs使用的Action是这个schema,只不过这个action只支持oauth登录,如果以某个方式拿到oauth之后的user_access_token然后,就可以将这个当作插件放到NextChat内部使用。

但是,我只有myaidrive的free帐号,不知道怎么拿到可以调用api的apikey

{
    "openapi": "3.1.0",
    "info": {
        "title": "AI Drive",
        "description": "Super-fast, interactive chats with PDFs of any size, complete with page references for fact checking.",
        "version": "v0.0.1"
    },
    "servers": [
        {
            "url": "https://aipdf.myaidrive.com",
            "description": "Production server"
        }
    ],
    "paths": {
        "/summarize_pdf": {
            "post": {
                "description": "Provide the text content of the PDF linked for summarization. Users can specify page range as an option.ALWAYS PROVIDE QUOTES AND PAGE CITATIONS.",
                "operationId": "summarize",
                "parameters": [],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/summarizeRequestSchema"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "200": {
                        "description": "Successful response"
                    }
                },
                "deprecated": false,
                "security": [],
                "x-openai-isConsequential": false
            }
        },
        "/upload_and_search_pdf": {
            "post": {
                "description": "Semantic query into a URL link to a document. THINK STEP BY STEP. ALWAYS PROVIDE QUOTES AND PAGE CITIATIONS. BREAK COMPLEX QUESTIONS INTO SEVERAL QUERIES.",
                "operationId": "upload_and_search_pdf",
                "parameters": [],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/upload_and_search_pdfRequestSchema"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "200": {
                        "description": "Successful response"
                    }
                },
                "deprecated": false,
                "security": [],
                "x-openai-isConsequential": false
            }
        },
        "/create_pdf_map": {
            "post": {
                "description": "Create a PDF map for the file the user uploaded to the GPT",
                "operationId": "createPDFMap",
                "parameters": [],
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/create_pdf_mapRequestSchema"
                            }
                        }
                    },
                    "required": true
                },
                "responses": {
                    "200": {
                        "description": "Successful response"
                    },
                    "500": {
                        "description": "Unable send file(s)."
                    }
                },
                "deprecated": false,
                "security": [],
                "x-openai-isConsequential": false
            }
        }
    },
    "components": {
        "schemas": {
            "upload_and_search_pdfRequestSchema": {
                "properties": {
                    "pdf_url": {
                        "type": "string",
                        "title": "pdf_url",
                        "description": "url where the PDF file is stored. e.g. https://myaidrive.com/eHrCoFs6i23ygrxL/Democracy_in.pdf"
                    },
                    "query": {
                        "type": "string",
                        "title": "query",
                        "description": "Query to perform semantic search."
                    }
                },
                "type": "object",
                "required": [
                    "pdf_url",
                    "query"
                ],
                "title": "upload_and_search_pdfRequestSchema"
            },
            "summarizeRequestSchema": {
                "properties": {
                    "pdf_url": {
                        "type": "string",
                        "title": "pdf_url",
                        "description": "url where the PDF file is stored. e.g. https://myaidrive.com/eHrCoFs6i23ygrxL/Democracy_in.pdf"
                    },
                    "start_page": {
                        "type": "integer",
                        "title": "start_page",
                        "description": "The starting page number for the summary. Optional.",
                        "minimum": 1,
                        "example": 1
                    },
                    "end_page": {
                        "type": "integer",
                        "title": "end_page",
                        "description": "The ending page number for the summary. Optional.",
                        "minimum": 1,
                        "example": 20
                    }
                },
                "type": "object",
                "required": [
                    "pdf_url"
                ],
                "title": "summarizeRequestSchema"
            },
            "create_pdf_mapRequestSchema": {
                "properties": {
                    "openaiFileIdRefs": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "description": "List of files to send to BE."
                        }
                    }
                },
                "type": "object",
                "required": [
                    "openaiFileIdRefs"
                ]
            }
        },
        "securitySchemes": {
            "apiKey": {
                "type": "apiKey"
            }
        }
    }
}

lloydzhou avatar Sep 09 '24 06:09 lloydzhou

@Why-SVIP

I find one GPTs, named PDF AI Reader Chat (4.1 ★), and get action import to NextChat.

then can talk with PDF url:

https://github.com/ChatGPTNextWeb/NextChat-Awesome-Plugins/tree/main/plugins/chatpdf

lloydzhou avatar Sep 09 '24 10:09 lloydzhou