GraphQAPipeline

org.llm4s.knowledgegraph.query.GraphQAPipeline
class GraphQAPipeline(llmClient: LLMClient, graphStore: GraphStore, config: GraphQAConfig)

Graph-guided question answering pipeline.

Uses graph structure to provide rich context for LLM answers. The pipeline follows the pattern: identify entities -> traverse for context -> rank entities -> generate answer.

Multi-hop traversal follows relationship chains to gather evidence beyond direct neighbors. Citations track which nodes and edges contributed to the answer.

Value parameters

config

Pipeline configuration

graphStore

The graph store containing the knowledge graph

llmClient

The LLM client for entity identification and answer generation

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def ask(question: String): Result[GraphQAResult]

Answers a natural language question using graph-guided context.

Answers a natural language question using graph-guided context.

Pipeline steps:

  1. Identify entities mentioned in the question
  2. Translate question to graph query
  3. Execute query to gather context subgraph
  4. Rank entities by importance (if enabled)
  5. Generate answer with graph context and citations

Value parameters

question

The natural language question

Attributes

Returns

Right(result) with answer and citations, Left(error) on failure

def askWithQuery(question: String, query: GraphQuery): Result[GraphQAResult]

Answers a question with an explicit pre-built graph query (skipping NL translation).

Answers a question with an explicit pre-built graph query (skipping NL translation).

Useful when the caller already knows the appropriate query structure.

Value parameters

query

The pre-built graph query to execute

question

The natural language question for the answer generation step

Attributes

Returns

Right(result) with answer and citations, Left(error) on failure