summaryrefslogtreecommitdiff
path: root/py/types.py
blob: 4eb0ccc355a67d2651edd44319750645c66ccd16 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from collections.abc import Sequence, Mapping
from typing import TypedDict, Literal, Union, List


class AIProvider(Protocol):

  def __init__(self, config: Mapping[str, str]) -> None:
      pass

  def request(self, messages: Sequence[Message]) -> Generator[str]:
      pass

class Message(TypedDict):
    role: str
    content: str
    type: str


class TextContent(TypedDict):
    type: Literal['text']
    text: str

class ImageUrlContent(TypedDict):
    type: Literal['image_url']
    image_url: dict[str, str]  # {'url': str}

MessageContent = Union[TextContent, ImageUrlContent]

class Message(TypedDict):
    role: Literal['system', 'user', 'assistant']
    content: List[MessageContent]