Skip to content
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 1cdace9

Browse files
fix: fix types
1 parent e09d261 commit 1cdace9

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

literalai/exporter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
from opentelemetry.sdk.trace import ReadableSpan
44
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
5-
from typing import Dict, List, Optional, Sequence, cast
5+
from typing import Dict, List, Optional, Sequence, Union, cast
66
import logging
77

88

@@ -149,13 +149,13 @@ def _create_step_from_span(self, span: ReadableSpan) -> Step:
149149
"id": str(span.context.span_id) if span.context else None,
150150
"name": span_props.get("name", span.name),
151151
"type": "llm",
152-
"metadata": self._extract_json(span_props.get("metadata", "{}")),
152+
"metadata": self._extract_json(str(span_props.get("metadata", "{}"))),
153153
"startTime": start_time,
154154
"endTime": end_time,
155155
"threadId": span_props.get("thread_id"),
156156
"parentId": span_props.get("parent_id"),
157157
"rootRunId": span_props.get("root_run_id"),
158-
"tags": self._extract_json(span_props.get("tags", "[]")),
158+
"tags": self._extract_json(str(span_props.get("tags", "[]"))),
159159
"input": {
160160
"content": (
161161
generation_content["messages"]
@@ -218,7 +218,7 @@ def _extract_messages(
218218

219219
return messages
220220

221-
def _extract_json(self, data: str) -> Dict | List | str:
221+
def _extract_json(self, data: str) -> Union[Dict, List, str]:
222222
try:
223223
content = json.loads(data)
224224
except Exception:

mypy.ini

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ ignore_missing_imports = True
88
ignore_missing_imports = True
99

1010
[mypy-langchain_community.*]
11-
ignore_missing_imports = True
11+
ignore_missing_imports = True
12+
13+
[mypy-traceloop.*]
14+
ignore_missing_imports = True

0 commit comments

Comments
 (0)