Skip to content

Commit

Permalink
update messages[].content type (#193)
Browse files Browse the repository at this point in the history
* update messages[].content type

* remove type ignore

* Bump to version 1.2.13
  • Loading branch information
orangetin authored Sep 25, 2024
1 parent 2a3fec6 commit ec0772b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ build-backend = "poetry.masonry.api"

[tool.poetry]
name = "together"
version = "1.2.12"
version = "1.2.13"
authors = [
"Together AI <[email protected]>"
]
Expand Down
4 changes: 2 additions & 2 deletions src/together/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, client: TogetherClient) -> None:
def create(
self,
*,
messages: List[Dict[str, str]],
messages: List[Dict[str, Any]],
model: str,
max_tokens: int | None = None,
stop: List[str] | None = None,
Expand All @@ -39,7 +39,7 @@ def create(
n: int | None = None,
safety_model: str | None = None,
response_format: Dict[str, str | Dict[str, Any]] | None = None,
tools: Dict[str, str | Dict[str, Any]] | None = None,
tools: List[Dict[str, Any]] | None = None,
tool_choice: str | Dict[str, str | Dict[str, str]] | None = None,
**kwargs: Any,
) -> ChatCompletionResponse | Iterator[ChatCompletionChunk]:
Expand Down
17 changes: 16 additions & 1 deletion src/together/types/chat_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,24 @@ class ToolCalls(BaseModel):
function: FunctionCall | None = None


class ChatCompletionMessageContentType(str, Enum):
TEXT = "text"
IMAGE_URL = "image_url"


class ChatCompletionMessageContentImageURL(BaseModel):
url: str


class ChatCompletionMessageContent(BaseModel):
type: ChatCompletionMessageContentType
text: str | None = None
image_url: ChatCompletionMessageContentImageURL | None = None


class ChatCompletionMessage(BaseModel):
role: MessageRole
content: str | None = None
content: str | List[ChatCompletionMessageContent] | None = None
tool_calls: List[ToolCalls] | None = None


Expand Down

0 comments on commit ec0772b

Please sign in to comment.