Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter Extraction #209

Open
LLMuser opened this issue Aug 13, 2024 · 2 comments
Open

Parameter Extraction #209

LLMuser opened this issue Aug 13, 2024 · 2 comments
Labels
question Further information is requested

Comments

@LLMuser
Copy link

LLMuser commented Aug 13, 2024

Hi all,

there is a manual for parameter extraction:
https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/node/parameter-extractor.md

But I don´t get the workflow. Can someone explain or even can @AllenWriter share the workflow?

Cheers!

@dosubot dosubot bot added the question Further information is requested label Aug 13, 2024
Copy link

dosubot bot commented Aug 13, 2024

Hi @LLMuser, I'm here to help you with any questions or issues you have while waiting for a human maintainer. If you need assistance, feel free to ask!

The workflow for parameter extraction involves several key steps:

1. Definition

Use a Large Language Model (LLM) to infer and extract structured parameters from natural language for subsequent tool invocation or HTTP requests. The parameter extractor converts natural language into tool-recognizable parameters.

2. Scenarios

  1. Extracting key parameters required by tools from natural language:

    • Example: For an Arxiv paper retrieval application, the parameter extractor can extract the paper ID from a query and use it as a tool parameter for precise querying.
    • Example Query: "What is the content of this paper: 2405.10739"
    • Extracted Parameter: 2405.10739
  2. Converting text to structured data:

    • Example: In a long story iteration generation application, the parameter extractor converts chapter content in text format to an array format for multi-round generation processing by the iteration node.
  3. Extracting structured data and using the HTTP Request:

    • Example: The parameter extractor can be used to request any accessible URL, suitable for obtaining external retrieval results, webhooks, generating images, etc.

3. How to Configure

Configuration Steps:

  1. Select the input variable: Usually the variable input for parameter extraction.
  2. Choose the model: The parameter extractor relies on the LLM's inference and structured generation capabilities.
  3. Define the parameters to extract: These can be manually added or quickly imported from existing tools.
  4. Write instructions: Providing examples can help the LLM improve the effectiveness and stability of extracting complex parameters.

Advanced Settings:

Inference Mode:

  • Function Call/Tool Call
  • Prompt

Memory:

  • When enabled, each input to the question classifier will include the chat history to help the LLM understand the context.

Output Variables:

  • Extracted defined variables
  • Node built-in variables:
    • __is_success Number: Extraction success status (1 for success, 0 for failure).
    • __reason String: Extraction error reason.

Example Workflow: Long Article Iteration Generator

  1. Start Node: Enter the story title and outline.
  2. Generate Subtitles and Outlines Node: Convert the story title and outline into complete text.
  3. Extract Subtitles and Outlines Node: Convert the story text into an array structure. The parameter to extract is sections, and the parameter type is Array[Object].
  4. Iteration Node: Use the array-formatted story outline as the input and process it within the iteration node using an LLM Node.
  5. Direct Answer Node: Achieve streaming output after each iteration.

Detailed Configuration Steps:

  1. Configure the story title (title) and outline (outline) in the Start Node.
  2. Use a Generate Subtitles and Outlines Node to convert the story title and outline into complete text.
  3. Use a Extract Subtitles and Outlines Node to convert the story text into an array (Array) structure.
  4. Use the array-formatted story outline as the input for the iteration node and process it within the iteration node using an LLM Node.
  5. Configure a Direct Reply Node inside the iteration node to achieve streaming output after each iteration.
  6. Complete debugging and preview.

This example demonstrates how parameter extraction can be used to convert text into structured data, which is then processed iteratively to generate content for each chapter of a long story [1][2][3].

To continue talking to Dosu, mention @dosu.

@AllenWriter
Copy link
Collaborator

Yes, how can I help you? To explain it in a more intuitive way, the parameter extraction node is used to convert natural language into structured content, such as JSON format content, to facilitate content processing in the next nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants