Skip to content

Commit

Permalink
fix: removed use of NotRequired for TypedDict (not in Python 3.10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 14, 2024
1 parent bb3d9a5 commit cfce130
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions gptme/llm_anthropic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from collections.abc import Generator
from typing import Literal, NotRequired, TypedDict
from typing import Literal, TypedDict
from typing_extensions import Required

from anthropic import Anthropic

Expand All @@ -22,11 +23,11 @@ def get_client() -> Anthropic | None:
return anthropic


class MessagePart(TypedDict):
type: Literal["text", "image_url"]
text: NotRequired[str]
image_url: NotRequired[str]
cache_control: NotRequired[dict[str, str]]
class MessagePart(TypedDict, total=False):
type: Required[Literal["text", "image_url"]]
text: str
image_url: str
cache_control: dict[str, str]


def chat(messages: list[Message], model: str) -> str:
Expand Down

0 comments on commit cfce130

Please sign in to comment.