NativeQueryGenerator

org.llm4s.knowledgegraph.query.NativeQueryGenerator
class NativeQueryGenerator(llmClient: LLMClient)

Generates native graph query strings (Cypher, Gremlin, SPARQL) from natural language or structured GraphQuery operations using an LLM.

This is an extension point for graph databases that support native query languages. The primary query path uses GraphQueryExecutor against the GraphStore trait; this generator provides an alternative for engines where native queries are more efficient.

Value parameters

llmClient

The LLM client to use for query generation

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def fromGraphQuery(query: GraphQuery, language: QueryLanguage, schemaContext: String): Result[NativeQuery]

Generates a native query from a structured GraphQuery.

Generates a native query from a structured GraphQuery.

Value parameters

language

The target query language

query

The structured graph query

schemaContext

Optional schema description for the target database

Attributes

Returns

Right(nativeQuery) on success, Left(error) on failure

def generate(question: String, language: QueryLanguage, schemaContext: String): Result[NativeQuery]

Generates a native query from a natural language question.

Generates a native query from a natural language question.

Value parameters

language

The target query language

question

The natural language question

schemaContext

Optional schema description for the target database

Attributes

Returns

Right(nativeQuery) on success, Left(error) on failure