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

[BUG] Langchain vs LangChain in providers #1454

Closed
ThomasZiegenhein opened this issue Sep 12, 2024 · 5 comments
Closed

[BUG] Langchain vs LangChain in providers #1454

ThomasZiegenhein opened this issue Sep 12, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ThomasZiegenhein
Copy link

Bug Description
import error

To Reproduce
from trulens.providers.langchain import LangChain (see https://www.trulens.org/reference/trulens/providers/langchain/#trulens.providers.langchain)

Expected behavior
No import error

Relevant Logs/Tracebacks

Environment:

  • OS: Ubuntu
  • Python Version: 3.12
  • TruLens version
    trulens-core==1.0.1
    trulens-feedback==1.0.1
    trulens-providers-langchain==1.0.1

Additional context
Probably Typo in Documentation, either change Documentation or go with LangChain for object name

@ThomasZiegenhein ThomasZiegenhein added the bug Something isn't working label Sep 12, 2024
Copy link

dosubot bot commented Sep 12, 2024

I found a similar closed issue: import Tru requires openai, which was resolved by making OpenAI optional through this pull request [1].

Regarding your specific issue, the LangChain class has been deprecated. You should update your import statement to use the new module path. Use the following import statement instead:

from trulens.apps.langchain import TruChain

Additionally, ensure you have the trulens-apps-langchain package installed by running:

pip install trulens-apps-langchain

This should resolve the import error you're encountering [2][3][4].

To continue talking to Dosu, mention @dosu.

@sfc-gh-jreini
Copy link
Contributor

@dosu you are confusing tru chain used for wrapping langchain apps and the langchain feedback provider.

Copy link

dosubot bot commented Sep 12, 2024

I apologize for the confusion. TruChain is used for wrapping LangChain applications to inspect and evaluate their internals, while the LangChain feedback provider is used for evaluating specific metrics such as context relevance.

For example, to instrument a LangChain application with TruChain:

from trulens_eval import TruChain
tru_recorder = TruChain(rag_chain)

To use the LangChain feedback provider for evaluating metrics:

from trulens_eval.feedback.provider import OpenAI
from trulens_eval.feedback import Feedback
import numpy as np

provider = OpenAI()

context = TruChain.select_context(rag_chain)

f_context_relevance = (
    Feedback(provider.context_relevance)
    .on_input()
    .on(context)
    .aggregate(np.mean)
)

Additionally, note that the LangChain provider cannot be used in deferred mode due to inconsistent serialization capabilities of LangChain apps [1].

To continue talking to Dosu, mention @dosu.

@ThomasZiegenhein
Copy link
Author

Sorry wasn't 100% clear I guess, the Example in the documentation says:

from trulens.providers.langchain import LangChain

but the object inside the providers is called Langchain, so what will work:

from trulens.providers.langchain import Langchain

... took some time for me to find that out, perhaps changing the documentation is the easiest way.

Thanks

@sfc-gh-jreini
Copy link
Contributor

sfc-gh-jreini commented Sep 12, 2024

Sorry for the confusion here @ThomasZiegenhein - we'll fix this in docs, and also look to standardize how we name langchain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants