8000 #1558 - Add a LLM-based TextExtractor (OpenAI API compatible) by rzo1 · Pull Request #1559 · apache/stormcrawler · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

#1558 - Add a LLM-based TextExtractor (OpenAI API compatible) #1559

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

rzo1
Copy link
Contributor
@rzo1 rzo1 commented Jun 13, 2025

Thank you for contributing to Apache StormCrawler.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes

  • Is there a issue associated with this PR? Is it referenced in the commit message?

  • Does your PR title start with #XXXX where XXXX is the issue number you are trying to resolve?

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit?

  • Is the code properly formatted with mvn git-code-format:format-code -Dgcf.globPattern="**/*" -Dskip.format.code=false?

For code changes

  • Have you ensured that the full suite of tests is executed via mvn clean verify?
  • Have you written or updated unit tests to verify your changes?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file?

Note

This PR introduces a new TextExtractor implementation — OpenAITextExtractor — which utilizes a Large Language Model (LLM) via an OpenAI-compatible API to extract meaningful content from HTML documents. This allows for semantically rich, context-aware extraction far beyond traditional rule-based methods. Traditional extraction using static rules is brittle and struggles with modern, dynamic layouts. Leveraging LLMs like GPT-4 or LLaMA 3 enables understanding of HTML semantics, resulting in improved text extraction quality.

Key Features are:

  • Supports OpenAI-compatible endpoints (e.g., Ollama, OpenRouter, Azure OpenAI)
  • Configurable prompts for both system and user messages
  • Optional user-defined "request" for fine-grained control (e.g., "only extract article body")
  • Hook interface (LlmResponseListener) for logging, monitoring, or billing (which is needed if you rely on a 3rd party vendor for inference)

Breaking Change (Potential)

This change renames the previously default TextExtractor class and introduces a new TextExtractor interface, making the implementation pluggable. While this may be considered a breaking change, the existing implementation was used privately and not designed for public extensibility. Therefore, in practice, it should be safe — but feedback is welcome.

@rzo1 rzo1 requested review from jnioche, tballison and mvolikas June 13, 2025 07:14
@rzo1 rzo1 force-pushed the genai-text-extractor branch from 5cbb8f7 to b130005 Compare June 13, 2025 07:15
@jnioche
Copy link
Contributor
jnioche commented Jun 13, 2025

looks good at first glance - maybe a more specific name for the module? openai-extractor ?
or will the module contain other types of resources in the long run? e.g. named entities extraction & normalisation?

@rzo1
Copy link
Contributor Author
rzo1 commented Jun 13, 2025

looks good at first glance - maybe a more specific name for the module? openai-extractor ? or will the module contain other types of resources in the long run? e.g. named entities extraction & normalisation?

In theory, we could add more functionality to it (such as ParseFilters or similar). Other LLM-based crawelrs have a rich feature set, which we could also add to it.

However, I am open to rename it. We could call it stormcrawler-llm, stormcrawler-llm-extractor, stormcrawler-llm-support, or alike. Totally open :) I am not good at naming.

@jnioche
Copy link
Contributor
jnioche commented Jun 13, 2025

However, I am open to rename it. We could call it stormcrawler-llm, stormcrawler-llm-extractor, stormcrawler-llm-support, or alike. Totally open :) I am not good at naming.

the 'stormcrawler' part is redundant. Maybe 'ai' is fine as it is

Copy link
Contributor
@jnioche jnioche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

3 participants
0