openlit: [Bug]: App fails when OpenLIT is used
π Whatβs Going Wrong?
I have a small LangChain-based app that works. When I add openlit.init(), it fails to start with the following exceptions:
Failed to instrument transformers: No module named 'transformers.pipelines'; 'transformers' is not a package
...
File "/Users/User/Library/Caches/pypoetry/virtualenvs/librefactor-k7sXJnK--py3.12/lib/python3.12/site-packages/langchain_community/embeddings/bedrock.py", line 150, in _embedding_func
raise ValueError(f"Error raised by inference endpoint: {e}")
ValueError: Error raised by inference endpoint: 'SSO' object has no attribute 'invoke_model'
If I remove transformers package it complains about the absense:
DependencyConflict: requested: "transformers >= 4.39.3" but found: "None"
π΅οΈ Steps to Reproduce
I have an app that makes use of the following:
- langchain 0.2.5
- chromadb 0.5.3
- Amazon Bedrock with Claude 3 and Titan v2 Embeddings
Here is the code with logic stripped for brevity:
import openlit
from langchain_community.embeddings.bedrock import BedrockEmbeddings
from langchain_community.vectorstores.chroma import Chroma
from langchain_aws import ChatBedrock
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
openlit.init()
text_for_search = ""
be = BedrockEmbeddings(model_id='amazon.titan-embed-text-v2:0')
ch = Chroma(persist_directory='./chroma', embedding_function=be)
sres = ch.similarity_search_with_score(query=text_for_search)
prompt = """prompt {input} {search_result}"""
llm = ChatBedrock(model_id="anthropic.claude-3-opus-20240229-v1:0")
prompt = ChatPromptTemplate.from_template(prompt)
output_parser = StrOutputParser()
chain = prompt | llm | output_parser
r = chain.invoke({"input": "some input", "search_result": sres[0][0].page_content})
When I comment out openlit.init(), it works.
π― What Did You Expect?
The app gets instrumented with traces.
πΈ Any Screenshots?
Pictures can say a thousand words and can be super helpful!
π» Your Setup
- OpenLIT Version: 1.14.1
- Deployment Method: Docker
π Additional Notes
Got more to say? Tell us here.
π Want to Help Make It Happen?
- Yes, Iβd like to volunteer and help out with this!
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (10 by maintainers)
Commits related to this issue
- [Fix]: Fix Langchain Instrumentation issues from #305, #301, #297 (#313) — committed to openlit/openlit by patcher9 2 years ago
Hi @patcher9
Unfortunately the error persists. Here is the full trace. I suspect that may be connected to the fact Iβm authenticating to AWS using SSO.