dd-trace-py icon indicating copy to clipboard operation
dd-trace-py copied to clipboard

Feature Request: [LLMObs] Support Automatic spans for `langchain_community`'s tools and retriever.

Open kimwonj77 opened this issue 1 year ago • 3 comments

Summary of problem

We're using Langchain community's tools via langchain.agents.load_tools.load_tools, and it seems like dd-trace-py is not automatically adding spans to it. Just like Langchain's Workflow and LLM spans, automatic integration with Langchain Community tools is needed for tracing. (And also, an option to turn it on and off, if possible.)

Added on May 31: We also discovered that Langchain Community's retriever does not have automatic spans. Additionally, the function langchain.tools.retriever.create_retriever_tool makes it difficult to add spans to the vectorstore/retriever.

Which version of dd-trace-py are you using?

538a0244aca41c032a06519fc84f7aa406f92115

Which version of pip are you using?

  • pip 23.3.1 from [redacted]/python3.12/site-packages/pip (python 3.12)

Which libraries and their versions are you using?

`pip freeze` ddtrace @ git+https://github.com/datadog/dd-trace-py@538a0244aca41c032a06519fc84f7aa406f92115

langchain==0.1.16 langchain-community==0.0.34 langchain-core==0.1.46 langchain-openai==0.1.4 langchain-text-splitters==0.0.1 langchainhub==0.1.15 langdetect==1.0.9 langsmith==0.1.51 openai==1.23.6

How can we reproduce your problem?

Here's an example from their documentation: https://python.langchain.com/v0.1/docs/integrations/tools/search_tools/

Added on May 31: Here's Retriever too. https://python.langchain.com/v0.1/docs/use_cases/question_answering/conversational_retrieval_agents/

What is the result that you get?

image

What is the result that you expected?

Tools should be on between openai.request

kimwonj77 avatar May 29 '24 03:05 kimwonj77

Thank you for reporting this behavior, @kimwonj77. We'll look into it.

cc @Yun-Kim

emmettbutler avatar May 29 '24 18:05 emmettbutler

Hi @kimwonj77, thanks for making this feature request! The LLM Observability team is looking into this and will likely be able to get this work started in Q3 - please keep an eye out in the upcoming months.

Yun-Kim avatar May 30 '24 17:05 Yun-Kim

Thanks for the response!

I also added information about the Retriever (Vectorstore) span, as we discovered that adding a span to the retriever is not straightforward (we had to 'patch' it ourselves). I believe handling this within dd-trace-py would be more appropriate. Therefore, I added this information to the same issue as it appears to be related.

If you need a separate issue for the retriever, I will do that.

kimwonj77 avatar May 31 '24 08:05 kimwonj77

This issue has been automatically closed after a period of inactivity. If it's a feature request, it has been added to the maintainers' internal backlog and will be included in an upcoming round of feature prioritization. Please comment or reopen if you think this issue was closed in error.

github-actions[bot] avatar Oct 29 '24 00:10 github-actions[bot]