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

TruLens/Pydantic Compatibility #97

Open
CamDuffy1 opened this issue Feb 20, 2024 · 1 comment
Open

TruLens/Pydantic Compatibility #97

CamDuffy1 opened this issue Feb 20, 2024 · 1 comment

Comments

@CamDuffy1
Copy link

CamDuffy1 commented Feb 20, 2024

TruLens is a tool that can be used to objectively evaluate a RAG application based on the following metrics (among others):

  1. Answer relevance (How relevant is the response to the query?)
  2. Context relevance (How relevant is the retrieved context to the query?)
  3. Groundedness (How well does the retrieved context support the response?)

trulens-eval is the Python library used to implement TruLens through code. Unfortunately, there are conflicting package dependencies between trulens-eval and other libraries used within SEC Insights. This prevents the use of TruLens to evaluate the RAG performance of SEC Insights.

The latest version of trulens-eval (0.23.0 at the time of writing) conflicts with the version of Pydantic required by the SEC Insights backend.

SEC Insights - Package Conflict - 01

0.17.0 is the latest version of trulens-eval that is compatible with the required version of Pydantic. However, this version of trulens-eval needs an older version of the OpenAI library, which conflicts with the version needed by llama-index. Because of this, trulens-eval 0.17.0 can't be used to create the feedback functions it needs to evaluate RAG performance.

Pydantic version >=2.0 is required by more recent versions of trulens-eval (such as 0.23.0) that are compatible with the OpenAI version (1.5.0) used by SEC Insights. The Pydantic Schemas for the API component of SEC Insights were written using Pydantic version ^1.10.8. Pydantic v2 introduces breaking changes from earlier versions, so legacy Pydantic code needs to be updated for compatibility with versions >=2.0.

Pydantic v2 still includes its v1 features, which can be accessed by importing through pydantic.v1. I installed Pydantic 2.6.1 and updated the existing Pydantic code in SEC Insights to be imported this way. This resulted in an internal server error (500) when trying to access the API.

SEC Insights - API Error - 01
(from the browser at https://<codespace-name>-8000.app.github.dev/docs)

SEC Insights - API Error - 02
(from the command line)

Pydantic provides a code transformation tool to help with migrating code from v1 to v2. I used this tool to update the Pydantic code in the backend directory, however I was not able to start the backend after doing so. Upon running the make run command from the backend directory, I received the following error related to Pydantic models:

SEC Insights - Make Run Pydantic Error - 01

Is there a known workaround to make SEC Insights compatible with Pydantic v2, or plans to upgrade the backend Pydantic code?

@CamDuffy1 CamDuffy1 changed the title TruLens Compatibility TruLens/Pydantic Compatibility Feb 20, 2024
@ashleych
Copy link

Facing similar issues with pydantic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants