MCPcopy
hub / github.com/microsoft/agent-lightning / make_llm_span

Function make_llm_span

tests/adapter/test_triplet_trace_tree.py:117–143  ·  view source on GitHub ↗
(
    span_id: str,
    *,
    parent_id: str,
    start: float,
    end: float,
    prompt_ids: Optional[List[int]] = None,
    response_ids: Optional[List[int]] = None,
    response_id: Optional[str] = None,
    extra_attrs: Optional[Dict[str, Any]] = None,
)

Source from the content-addressed store, hash-verified

115
116
117def make_llm_span(
118 span_id: str,
119 *,
120 parent_id: str,
121 start: float,
122 end: float,
123 prompt_ids: Optional[List[int]] = None,
124 response_ids: Optional[List[int]] = None,
125 response_id: Optional[str] = None,
126 extra_attrs: Optional[Dict[str, Any]] = None,
127) -> Span:
128 attrs: Dict[str, Any] = {
129 "prompt_token_ids": prompt_ids or [],
130 "response_token_ids": response_ids or [],
131 }
132 if response_id is not None:
133 attrs["gen_ai.response.id"] = response_id
134 if extra_attrs:
135 attrs.update(extra_attrs)
136 return make_span(
137 span_id,
138 "openai.chat.completion",
139 parent_id=parent_id,
140 start_time=start,
141 end_time=end,
142 attributes=attrs,
143 )
144
145
146def reward_attributes(value: float) -> Dict[str, Any]:

Calls 2

make_spanFunction · 0.70
updateMethod · 0.45

Tested by

no test coverage detected