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

feat: Langfuse integration, system-wide tracing configuration (LangSmith&Langfuse) #253

Merged
merged 2 commits into from
Sep 30, 2024

Conversation

maciejmajek
Copy link
Member

@maciejmajek maciejmajek commented Sep 27, 2024

Purpose

Tracing agents is crucial for debugging, transparency, safety and more. At the moment, the code only works with LangSmith tracing (a paid solution). RAI has to provide an alternative, like LangFuse.

Proposed Changes

What does this PR add, remove or fix?

Issues

  • Links to relevant issues

Testing

Setup langfuse: https://langfuse.com/docs/deployment/local
Go to http://localhost:3000, create account, organization and project.
configure langfuse tracing in config.toml

[tracing.langfuse]
use_langfuse = true
host = "http://localhost:3000"

Add the config to the main agent.invoke

from rai.utils.model_initialization import get_llm_model, get_tracing_callbacks
...
self.agent.invoke(
            {"messages": self.history}, config={"callbacks": get_tracing_callbacks()}
        )
image image

@maciejmajek maciejmajek linked an issue Sep 27, 2024 that may be closed by this pull request
@maciejmajek maciejmajek marked this pull request as ready for review September 28, 2024 11:42
@maciejmajek maciejmajek changed the title feat: LangFuse integration, system-wide tracing configuration feat: LangFuse integration, system-wide tracing configuration (LangSmith&LangFuse) Sep 28, 2024
@maciejmajek maciejmajek changed the title feat: LangFuse integration, system-wide tracing configuration (LangSmith&LangFuse) feat: Langfuse integration, system-wide tracing configuration (LangSmith&Langfuse) Sep 28, 2024
@boczekbartek
Copy link
Member

@maciejmajek Such a great idea to have an open-source alternative for paid services!

Please document how to use Langfuse (and LangSmith if possible). I think new users might not know that it's possible.

How about adding it to:

@maciejmajek
Copy link
Member Author

Multimodal tracing works in langsmith, langfuse has limited capability (works with links, but not with base64 images that we use yet)
image

Copy link
Member

@adamdbrw adamdbrw left a comment

Choose a reason for hiding this comment

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

Some suggestions, rather minor

docs/tracing.md Outdated Show resolved Hide resolved
docs/tracing.md Outdated Show resolved Hide resolved
docs/tracing.md Outdated

When enabled, LangSmith tracing will automatically be set up with the following environment variables:

### Langfuse
Copy link
Member

Choose a reason for hiding this comment

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

I would always start with the open source option when reading from the top, and make the distinction extra clear, i.e.:

Langfuse (open-source)

LangSmith (closed-source, paid)

docs/tracing.md Outdated Show resolved Hide resolved
docs/tracing.md Outdated Show resolved Hide resolved
@@ -94,6 +94,7 @@ agent.invoke({"messages": ["Please pick up an object and scan it."]})

Additional resources:

- [Tracing](tracing.md) configuration.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- [Tracing](tracing.md) configuration.
- [Tracing](tracing.md) configuration for AI models.

@adamdbrw
Copy link
Member

Important step for full open-source tool set

docs/developer_guide.md Outdated Show resolved Hide resolved
> implement get_tracing_callbacks for system wide use cases

fix: proper config parsing
Apply suggestions from code review

Co-authored-by: Adam Dąbrowski <adam.dabrowski@robotec.ai>

docs: rewrite tracing.md (prioritize open source solution), fix misleading info
@maciejmajek maciejmajek merged commit 3282d76 into development Sep 30, 2024
4 checks passed
@maciejmajek maciejmajek deleted the feat/langfuse-tracing branch September 30, 2024 11:28
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

Successfully merging this pull request may close these issues.

Implement 1st class support for tracing with LangFuse
3 participants