Skip to content

Commit

Permalink
fix: add requirement to LlamaIndex instrumentation import (#110)
Browse files Browse the repository at this point in the history
* fix: add requirement to LlamaIndex instrumentation import

* fix: move import to instrument method
  • Loading branch information
desaxce authored Aug 19, 2024
1 parent 9cecb29 commit 5151ac2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion literalai/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
ExperimentItemRunContextManager,
experiment_item_run_decorator,
)
from literalai.instrumentation.llamaindex import instrument_llamaindex
from literalai.instrumentation.mistralai import instrument_mistralai
from literalai.instrumentation.openai import instrument_openai
from literalai.observability.message import Message
Expand All @@ -25,6 +24,8 @@
)
from literalai.observability.thread import ThreadContextManager, thread_decorator

from literalai.requirements import check_all_requirements


class BaseLiteralClient:
api: Union[LiteralAPI, AsyncLiteralAPI]
Expand Down Expand Up @@ -92,6 +93,15 @@ def instrument_llamaindex(self):
"""
Instruments the Llama Index framework so that all RAG & LLM calls are logged to Literal AI.
"""

LLAMA_INDEX_REQUIREMENT = ["llama-index>=0.10.58"]

if not check_all_requirements(LLAMA_INDEX_REQUIREMENT):
raise Exception(
f"LlamaIndex instrumentation requirements not satisfied: {LLAMA_INDEX_REQUIREMENT}"
)
from literalai.instrumentation.llamaindex import instrument_llamaindex

instrument_llamaindex(self.to_sync())

def langchain_callback(
Expand Down

0 comments on commit 5151ac2

Please sign in to comment.