Skip to content

Commit

Permalink
fix: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
clementsirieix committed Dec 17, 2024
1 parent e09d261 commit 1cdace9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions literalai/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import json
from opentelemetry.sdk.trace import ReadableSpan
from opentelemetry.sdk.trace.export import SpanExporter, SpanExportResult
from typing import Dict, List, Optional, Sequence, cast
from typing import Dict, List, Optional, Sequence, Union, cast
import logging


Expand Down Expand Up @@ -149,13 +149,13 @@ def _create_step_from_span(self, span: ReadableSpan) -> Step:
"id": str(span.context.span_id) if span.context else None,
"name": span_props.get("name", span.name),
"type": "llm",
"metadata": self._extract_json(span_props.get("metadata", "{}")),
"metadata": self._extract_json(str(span_props.get("metadata", "{}"))),
"startTime": start_time,
"endTime": end_time,
"threadId": span_props.get("thread_id"),
"parentId": span_props.get("parent_id"),
"rootRunId": span_props.get("root_run_id"),
"tags": self._extract_json(span_props.get("tags", "[]")),
"tags": self._extract_json(str(span_props.get("tags", "[]"))),
"input": {
"content": (
generation_content["messages"]
Expand Down Expand Up @@ -218,7 +218,7 @@ def _extract_messages(

return messages

def _extract_json(self, data: str) -> Dict | List | str:
def _extract_json(self, data: str) -> Union[Dict, List, str]:
try:
content = json.loads(data)
except Exception:
Expand Down
5 changes: 4 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ ignore_missing_imports = True
ignore_missing_imports = True

[mypy-langchain_community.*]
ignore_missing_imports = True
ignore_missing_imports = True

[mypy-traceloop.*]
ignore_missing_imports = True

0 comments on commit 1cdace9

Please sign in to comment.