Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add requirement to LlamaIndex instrumentation import #110

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try that everything is still working? we could alias the import to avoid functions with the exact same name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't try to instrument llama index, just the regular literal client.
I'll run a couple of cookbooks and alias the import that's more neat.

Copy link
Contributor Author

@desaxce desaxce Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well:
image

instrument_llamaindex(self.to_sync())

def langchain_callback(
Expand Down
Loading