跳到主要内容

文档问答

此流程演示了向文件组件添加文件,以从您的本地计算机将文档加载到您的流程中。

先决条件

创建文档问答流程

  1. 从 Langflow 仪表板,点击新建流程
  2. 选择文档问答
  3. 文档问答流程被创建。

Document QA starter flow

This flow is composed of a chatbot with the Chat InputPromptLanguage model, and Chat Output components, but also incorporates a File component, which loads a file from your local machine. The Parser component converts the data from the File component into the Prompt component as {Document}.

The Prompt component is instructed to answer questions based on the contents of {Document}. This gives the OpenAI component context it would not otherwise have access to.

Run the document QA flow

  1. Add your OpenAI API key to the Language model model component. Optionally, create a global variable for the OpenAI API key.

    1. In the OpenAI API Key field, click Globe, and then click Add New Variable.
    2. In the Variable Name field, enter openai_api_key.
    3. In the Value field, paste your OpenAI API Key (sk-...).
    4. Click Save Variable.
  2. To select a document to load, in the File component, click the Select files button. Select a local file or a file loaded with File management, and then click Select file. The file name appears in the component.

  3. To run the flow, click  Playground. Enter a question about the loaded document's content. You should receive a contextual response indicating that the LLM has read your document.

Search