RobotecAI / rai

RAI is a multi-vendor agent framework for robotics, utilizing Langchain and ROS 2 tools to perform complex actions, defined scenarios, free interface execution, log summaries, voice interaction and more.
Apache License 2.0
164 stars 18 forks source link

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

Closed maciejmajek closed 2 months ago

maciejmajek commented 2 months ago

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

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
boczekbartek commented 2 months ago

@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 commented 2 months ago

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

image
adamdbrw commented 2 months ago

Important step for full open-source tool set