Skip to content

Utils

Utils module for Graph Data Store.

GraphitiRerankerType

Bases: str, Enum

Enum for Graphiti reranker types.

LightRAGLMInvokerAdapter(lm_invoker)

LMInvoker adapter for the LightRAG module.

This adapter is used to adapt the LMInvoker interface to the LightRAG module. It handles the conversion between different prompt formats and manages asynchronous invocation in a way that's compatible with nested event loops.

Initialize the LightRAGLMInvokerAdapter.

Parameters:

Name Type Description Default
lm_invoker BaseLMInvoker

The LM invoker to use.

required

__call__(prompt, system_prompt=None, history_messages=None, **kwargs) async

Make the adapter callable for compatibility with LightRAG.

Parameters:

Name Type Description Default
prompt str

The prompt to invoke the LM invoker with.

required
system_prompt str | None

The system prompt to format in string format. Defaults to None.

None
history_messages list[dict[str, Any]] | None

The history messages to format in OpenAI format. Defaults to None.

None
**kwargs Any

Additional keyword arguments for the LM invoker.

{}

Returns:

Name Type Description
str str

The response from the LM invoker.

__deepcopy__(memo)

Custom deepcopy implementation to handle non-serializable objects.

This method is called when copy.deepcopy() is invoked on this object. We create a new instance without deep-copying the invoker object which may contain non-serializable components.

Parameters:

Name Type Description Default
memo dict

Memoization dictionary for deepcopy process

required

Returns:

Name Type Description
LightRAGLMInvokerAdapter LightRAGLMInvokerAdapter

A new instance with the same invoker reference