rag.client_adapter

Adapt an FFAI client into a callable that returns a GenerationResult for RAG generation.

Adapt an FFAI client into a callable that returns a GenerationResult for RAG generation.

class ClientAdapter(client, **kwargs)[source]

Bases: object

Wrap an FFAI client into a callable that returns a GenerationResult.

Handles both synchronous and asynchronous generate_response methods, automatically awaiting coroutines when necessary.

Parameters:
  • client (Any) – An FFAI client instance with a generate_response method.

  • **kwargs (Any) – Extra keyword arguments forwarded to generate_response on every call.

__call__(prompt)[source]

Generate a response for the given prompt.

Parameters:

prompt (str) – The prompt string to send to the client.

Returns:

A GenerationResult containing the response text, usage, cost, and duration metadata.

Return type:

GenerationResult

Classes

class ClientAdapter(client, **kwargs)[source]

Bases: object

Wrap an FFAI client into a callable that returns a GenerationResult.

Handles both synchronous and asynchronous generate_response methods, automatically awaiting coroutines when necessary.

Parameters:
  • client (Any) – An FFAI client instance with a generate_response method.

  • **kwargs (Any) – Extra keyword arguments forwarded to generate_response on every call.

__call__(prompt)[source]

Generate a response for the given prompt.

Parameters:

prompt (str) – The prompt string to send to the client.

Returns:

A GenerationResult containing the response text, usage, cost, and duration metadata.

Return type:

GenerationResult