(
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,
)
| 115 | |
| 116 | |
| 117 | def 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 | |
| 146 | def reward_attributes(value: float) -> Dict[str, Any]: |
no test coverage detected