wandb / weave

Weave is a toolkit for developing AI-powered applications, built by Weights & Biases.
https://wandb.me/weave
Apache License 2.0
659 stars 49 forks source link

feat: ref expansion in the server #2137

Closed gtarpenning closed 2 weeks ago

gtarpenning commented 1 month ago

This PR implements server-side ref expansion in the calls query. When expand_columns are passed (dot.notation strings corresponding to columns), all refs in those exact columns will be expanded.

Example:

r = calls_query_stream(req=CallsQueryReq(project_id=client._project_id()))
# [{"id"...., "output": "weave:///object/...."}]
r = calls_query_stream(
     req=CallsQueryReq(
            project_id=client._project_id(),
            expand_columns=["output.object"],
     )
)
# [{"id"...., "output": {"object": {"hello": 123}}}]

In the case of nested ref expansion, where a field is requested inside an object that is itself a ref, multiple expand column strings must be provided. For example, to fully de-ref:

primative = 123
object2 = {"b": primative}
object3 = {"c": object2}

@weave.op
def fn():
   return object3

# to get 123: 
expand_columns = ["output", "output.c", "output.c.b"]

To do the above ref expansion performantly:

Known limitations:

Server PR:

circle-job-mirror[bot] commented 1 month ago

Preview this PR with FeatureBee: https://beta.wandb.ai/?betaVersion=5c8c8d78b0e2764523de41063df4099572d949db