langflow-ai / langflow

Langflow is a low-code app builder for RAG and multi-agent AI applications. It’s Python-based and agnostic to any model, API, or database.
http://www.langflow.org
MIT License
30.04k stars 3.79k forks source link

Error: cannot import name 'CreateTrace' from 'langfuse.callback' #1409

Closed Jotte92 closed 3 months ago

Jotte92 commented 7 months ago

Having an issue getting a response back from GPT when using a basic ConversationChain.

Terminal shows an error with langfuse being unable to import 'CreateTrace' from 'langfuse.callback'.

Can anyone help me on this one?

Screenshot 2024-02-08 at 8 37 31 am Screenshot 2024-02-08 at 8 37 42 am Screenshot 2024-02-08 at 8 39 07 am
dosubot[bot] commented 7 months ago

🤖

Hey @Jotte92! Nice to see you back here facing the digital challenges head-on. What's cooking in the code kitchen today?

The error you're encountering, "cannot import name 'CreateTrace' from 'langfuse.callback'", suggests that Python is unable to find the 'CreateTrace' class or function in the 'langfuse.callback' module. This could be due to a few reasons:

  1. The 'CreateTrace' class or function might have been removed or renamed in the version of Langfuse you're using (2.9.0). You should check the documentation or source code of Langfuse to confirm if 'CreateTrace' exists in the 'callback' module.

  2. There might be an issue with the installation of the Langfuse package. If the package is not properly installed, Python might not be able to find the 'CreateTrace' class or function. You can try reinstalling the package to see if it resolves the issue.

  3. The 'langfuse.callback' module might not be in the Python path. Python needs to know where to look for modules and packages, and it does this by using the Python path. If 'langfuse.callback' is not in the Python path, Python will not be able to import it.

In the Langflow codebase, the 'CreateTrace' is imported from 'langfuse.callback' in the 'get_callback' method of the 'LangfusePlugin' class:

from langfuse.callback import CreateTrace  # type: ignore

You should check the above points to resolve the issue. If the issue persists, you might need to contact the maintainers of the Langfuse package for further assistance.

As for the screenshots you've shared, I'm sorry but I'm unable to view images. If there's any additional information in the screenshots that you haven't mentioned, please provide that in text form.

Let me know if you need further assistance.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

Jotte92 commented 7 months ago

Solved by installing Langfuse v1.8.0

Inkognitoo commented 7 months ago

Same problem. But when I try to downgrade the langfuse version, I get an error: langflow 0.6.6 requires langfuse<3.0.0,>=2.9.0, but you have langfuse 1.8.0 which is incompatible.

Jotte92 commented 7 months ago

I got this error also however I was shocked to see it still installed. I uninstalled Langfuse and then reinstalled v1.8.0. I was also using terminal inside anaconda not sure if this makes a difference. Maybe check to see what version of langfuse you have after the error message.

flefevre commented 7 months ago

I have the same issue through a docker installation

flefevre commented 7 months ago

so iget into my docker

ser@466e8085241e:~/app$ pip show langfuse Name: langfuse Version: 2.9.0 Summary: A client library for accessing langfuse Home-page: Author: langfuse Author-email: developers@langfuse.com License: MIT Location: /home/user/.local/lib/python3.10/site-packages Requires: backoff, chevron, httpx, openai, pydantic, wrapt Required-by: langflow user@466e8085241e:~/app$ user@466e8085241e:~/app$ user@466e8085241e:~/app$ user@466e8085241e:~/app$ user@466e8085241e:~/app$ pip show langflow Name: langflow Version: 0.6.6 Summary: A Python package with a built-in web application Home-page: https://github.com/logspace-ai/langflow Author: Logspace Author-email: contact@logspace.ai License: MIT Location: /home/user/.local/lib/python3.10/site-packages Requires: alembic, anthropic, bcrypt, beautifulsoup4, boto3, cachetools, certifi, chromadb, cohere, docstring-parser, elasticsearch, extract-msg, faiss-cpu, fake-useragent, fastapi, fastavro, google-api-python-client, google-cloud-aiplatform, google-search-results, gunicorn, huggingface-hub, jina, jq, langchain, langchain-experimental, langchain-google-genai, langchain-openai, langfuse, llama-index, loguru, lxml, markupsafe, metal-sdk, metaphor-python, multiprocess, networkx, numexpr, openai, orjson, pandas, passlib, pgvector, pillow, pinecone-client, platformdirs, psycopg, psycopg-binary, psycopg2-binary, pyarrow, pyautogen, pydantic, pydantic-settings, pymongo, pypdf, pysrt, python-jose, python-multipart, pytube, qdrant-client, qianfan, rich, sqlmodel, supabase, tiktoken, typer, types-cachetools, unstructured, uvicorn, weaviate-client, websockets, wikipedia, zep-python

i have still the error

Traceback (most recent call last): langflow-1 | File "/home/user/.local/lib/python3.10/site-packages/langflow/processing/base.py", line 81, in get_result_and_steps langflow-1 | callbacks = setup_callbacks(sync=True, trace_id=trace_id, **kwargs) langflow-1 | File "/home/user/.local/lib/python3.10/site-packages/langflow/processing/base.py", line 23, in setup_callbacks langflow-1 | plugin_callbacks = plugin_service.get_callbacks(_id=trace_id) langflow-1 | File "/home/user/.local/lib/python3.10/site-packages/langflow/services/plugins/service.py", line 63, in get_callbacks langflow-1 | callback = plugin.get_callback(_id=_id) langflow-1 | File "/home/user/.local/lib/python3.10/site-packages/langflow/services/plugins/langfuse_plugin.py", line 67, in get_callback langflow-1 | from langfuse.callback import CreateTrace # type: ignore langflow-1 | ImportError: cannot import name 'CreateTrace' from 'langfuse.callback' (/home/user/.local/lib/python3.10/site-packages/langfuse/callback.py)

any idea?

prathigajd commented 7 months ago

@Jotte92 which langchain and langflow version your using ?

flefevre commented 7 months ago

Hello, personnaly i have tested several version of langflow/langfuse. sorry for my english, i am french...

please find here the minimum docker files to connect Ollama with LangFlow and WebUI with minimal configuration -DockerFile.langflow -docker-compose.yml -.env -one langflow flow to ollama

if you run "docker compose up" you should be able to load a model in webui connect to langflow with amin:123456 import the flow execute to see the error.

you can also verify:

but when calling from langflow, there is a problem of connexion...

hope it can hekp to detect where come the problem. langflow4cea2test.zip

flefevre commented 7 months ago

It seems to be related to https://github.com/logspace-ai/langflow/discussions/888