QuestionCondenser

org.llm4s.rag.QuestionCondenser
See theQuestionCondenser companion trait

Attributes

Companion
trait
Source
QuestionCondenser.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

A condenser from a function, for Java callers and where a lambda's type is not inferred.

A condenser from a function, for Java callers and where a lambda's type is not inferred.

Attributes

Source
QuestionCondenser.scala
def llm(client: LLMClient, options: CompletionOptions, systemPrompt: String, maxHistoryMessages: Int): QuestionCondenser

The built-in condenser: one client call that rewrites the question as a standalone one, given the history.

The built-in condenser: one client call that rewrites the question as a standalone one, given the history.

The history is sent as a transcript inside a single user message, after systemPrompt: the latest maxHistoryMessages user and assistant messages with text (tool messages and tool-call-only assistant messages are left out, as is anything older), each as User: or Assistant:, then the follow-up question.

Failure: a failed call fails the query with the client's error, unchanged, so a rate limit is still a recoverable RateLimitError; a blank reply falls back to the original question. To answer from the original question whenever the call fails, wrap it: QuestionCondenser((q, h) => condenser.condense(q, h).orElse(Right(q))).

With a tracer on the RAG (RAGConfig.withTracing), each call is traced and its usage tagged rag.condense.

Value parameters

client

the model to ask; a small, fast one is usually enough

maxHistoryMessages

how many of the latest history messages to send; a value below 1 makes every call a ValidationError

options

the completion options; temperature 0 by default

systemPrompt

the instruction; DefaultSystemPrompt by default

Attributes

Source
QuestionCondenser.scala

Concrete fields

How many of the latest history messages the built-in condenser sends, by default.

How many of the latest history messages the built-in condenser sends, by default.

Attributes

Source
QuestionCondenser.scala

The built-in condenser's completion options, by default: temperature 0, for a stable rewrite.

The built-in condenser's completion options, by default: temperature 0, for a stable rewrite.

Attributes

Source
QuestionCondenser.scala

The built-in condenser's system prompt: the standard condense-question instruction.

The built-in condenser's system prompt: the standard condense-question instruction.

Attributes

Source
QuestionCondenser.scala