langchain-ai / langserve

LangServe 🦜️🏓
Other
1.75k stars 184 forks source link

Request for a documented way to add metadata such as the git tag across all of the langserve endpoints #658

Open codekiln opened 1 month ago

codekiln commented 1 month ago

feature request - global metadata

Let's say I have n langserve endpoints running on a single microservice with a single git tag. I'd like to be able to add the git tag for the microservice as a metadata item to langsmith for all the langserve endpoints running on that microservice. Is there a way to do that in a uniform way?

existing try for workaround (working) - adding to each chain

Let's say I have six endpoints, and I try adding .with_config({"tags": ["top-level-tag"], "metadata": {"top-level-key": "top-level-value"}}), following the langsmith docs, since each chain is a runnable.

add_routes(app, chain_1, path="/chain_1")
add_routes(app, chain_2, path="/chain_2")
add_routes(app, chain_3, path="/chain_3")
add_routes(app, chain_4, path="/chain_4")
add_routes(
    app,
    chain_5.with_config(
        {"tags": ["top-level-tag"], "metadata": {"top-level-key": "top-level-value"}}
    ),
    path="/chain_5",
)
add_routes(app, chain_6, path="/chain_6")

When I call /chain_5, I'm not seeing tags or metadata in the trace in the feedback section, though I am seeing the trace in langsmith. Have I done this incorrectly? [UPDATE - My mistake, this is actually working correctly]