Skip to content

fix: add requirement to LlamaIndex instrumentation import #110

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

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Changes from 1 commit
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
7 changes: 6 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,12 @@
)
from literalai.observability.thread import ThreadContextManager, thread_decorator

from literalai.requirements import check_all_requirements

LLAMA_INDEX_REQUIREMENT = ["llama-index>=0.10.58"]
Copy link
Contributor

Choose a reason for hiding this comment

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

I am surprised mypy is not complaining since it is conditional and we use this function in the code. Why not move this logic in the client function?

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 was very surprised too.
Much better to move it to inside the method itself.

Side note, I noticed openai & mistralai instrumentations make sure of instrumenting only once with logic like:

global is_mistralai_instrumented
    if is_mistralai_instrumented:
        return

I wonder whether we should do that with LlamaIndex.

Copy link
Contributor

Choose a reason for hiding this comment

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

not sure, i think the llama index one is global by default?

if check_all_requirements(LLAMA_INDEX_REQUIREMENT):
from literalai.instrumentation.llamaindex import instrument_llamaindex


class BaseLiteralClient:
api: Union[LiteralAPI, AsyncLiteralAPI]
Expand Down
Loading