-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
672 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
clients/tabby-python-client/tabby_client/models/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
""" Contains all the data models used in inputs/outputs """ | ||
|
||
from .chat_completion_chunk import ChatCompletionChunk | ||
from .chat_completion_request import ChatCompletionRequest | ||
from .choice import Choice | ||
from .completion_request import CompletionRequest | ||
from .completion_response import CompletionResponse | ||
from .health_state import HealthState | ||
from .hit import Hit | ||
from .hit_document import HitDocument | ||
from .log_event_request import LogEventRequest | ||
from .message import Message | ||
from .search_response import SearchResponse | ||
from .segments import Segments | ||
from .snippet import Snippet | ||
from .version import Version | ||
|
||
__all__ = ( | ||
"ChatCompletionChunk", | ||
"ChatCompletionRequest", | ||
"Choice", | ||
"CompletionRequest", | ||
"CompletionResponse", | ||
"HealthState", | ||
"Hit", | ||
"HitDocument", | ||
"LogEventRequest", | ||
"Message", | ||
"SearchResponse", | ||
"Segments", | ||
"Snippet", | ||
"Version", | ||
) |
57 changes: 57 additions & 0 deletions
57
clients/tabby-python-client/tabby_client/models/chat_completion_chunk.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from typing import Any, Dict, List, Type, TypeVar | ||
|
||
import attr | ||
|
||
T = TypeVar("T", bound="ChatCompletionChunk") | ||
|
||
|
||
@attr.s(auto_attribs=True) | ||
class ChatCompletionChunk: | ||
""" | ||
Attributes: | ||
content (str): | ||
""" | ||
|
||
content: str | ||
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
content = self.content | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update(self.additional_properties) | ||
field_dict.update( | ||
{ | ||
"content": content, | ||
} | ||
) | ||
|
||
return field_dict | ||
|
||
@classmethod | ||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: | ||
d = src_dict.copy() | ||
content = d.pop("content") | ||
|
||
chat_completion_chunk = cls( | ||
content=content, | ||
) | ||
|
||
chat_completion_chunk.additional_properties = d | ||
return chat_completion_chunk | ||
|
||
@property | ||
def additional_keys(self) -> List[str]: | ||
return list(self.additional_properties.keys()) | ||
|
||
def __getitem__(self, key: str) -> Any: | ||
return self.additional_properties[key] | ||
|
||
def __setitem__(self, key: str, value: Any) -> None: | ||
self.additional_properties[key] = value | ||
|
||
def __delitem__(self, key: str) -> None: | ||
del self.additional_properties[key] | ||
|
||
def __contains__(self, key: str) -> bool: | ||
return key in self.additional_properties |
76 changes: 76 additions & 0 deletions
76
clients/tabby-python-client/tabby_client/models/chat_completion_request.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar | ||
|
||
import attr | ||
|
||
if TYPE_CHECKING: | ||
from ..models.message import Message | ||
|
||
|
||
T = TypeVar("T", bound="ChatCompletionRequest") | ||
|
||
|
||
@attr.s(auto_attribs=True) | ||
class ChatCompletionRequest: | ||
""" | ||
Example: | ||
{'messages': [{'content': 'What is tail recursion?', 'role': 'user'}, {'content': "It's a kind of optimization | ||
in compiler?", 'role': 'assistant'}, {'content': 'Could you share more details?', 'role': 'user'}]} | ||
Attributes: | ||
messages (List['Message']): | ||
""" | ||
|
||
messages: List["Message"] | ||
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
messages = [] | ||
for messages_item_data in self.messages: | ||
messages_item = messages_item_data.to_dict() | ||
|
||
messages.append(messages_item) | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update(self.additional_properties) | ||
field_dict.update( | ||
{ | ||
"messages": messages, | ||
} | ||
) | ||
|
||
return field_dict | ||
|
||
@classmethod | ||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: | ||
from ..models.message import Message | ||
|
||
d = src_dict.copy() | ||
messages = [] | ||
_messages = d.pop("messages") | ||
for messages_item_data in _messages: | ||
messages_item = Message.from_dict(messages_item_data) | ||
|
||
messages.append(messages_item) | ||
|
||
chat_completion_request = cls( | ||
messages=messages, | ||
) | ||
|
||
chat_completion_request.additional_properties = d | ||
return chat_completion_request | ||
|
||
@property | ||
def additional_keys(self) -> List[str]: | ||
return list(self.additional_properties.keys()) | ||
|
||
def __getitem__(self, key: str) -> Any: | ||
return self.additional_properties[key] | ||
|
||
def __setitem__(self, key: str, value: Any) -> None: | ||
self.additional_properties[key] = value | ||
|
||
def __delitem__(self, key: str) -> None: | ||
del self.additional_properties[key] | ||
|
||
def __contains__(self, key: str) -> bool: | ||
return key in self.additional_properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar | ||
|
||
import attr | ||
|
||
if TYPE_CHECKING: | ||
from ..models.hit_document import HitDocument | ||
|
||
|
||
T = TypeVar("T", bound="Hit") | ||
|
||
|
||
@attr.s(auto_attribs=True) | ||
class Hit: | ||
""" | ||
Attributes: | ||
score (float): | ||
doc (HitDocument): | ||
id (int): | ||
""" | ||
|
||
score: float | ||
doc: "HitDocument" | ||
id: int | ||
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict) | ||
|
||
def to_dict(self) -> Dict[str, Any]: | ||
score = self.score | ||
doc = self.doc.to_dict() | ||
|
||
id = self.id | ||
|
||
field_dict: Dict[str, Any] = {} | ||
field_dict.update(self.additional_properties) | ||
field_dict.update( | ||
{ | ||
"score": score, | ||
"doc": doc, | ||
"id": id, | ||
} | ||
) | ||
|
||
return field_dict | ||
|
||
@classmethod | ||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T: | ||
from ..models.hit_document import HitDocument | ||
|
||
d = src_dict.copy() | ||
score = d.pop("score") | ||
|
||
doc = HitDocument.from_dict(d.pop("doc")) | ||
|
||
id = d.pop("id") | ||
|
||
hit = cls( | ||
score=score, | ||
doc=doc, | ||
id=id, | ||
) | ||
|
||
hit.additional_properties = d | ||
return hit | ||
|
||
@property | ||
def additional_keys(self) -> List[str]: | ||
return list(self.additional_properties.keys()) | ||
|
||
def __getitem__(self, key: str) -> Any: | ||
return self.additional_properties[key] | ||
|
||
def __setitem__(self, key: str, value: Any) -> None: | ||
self.additional_properties[key] = value | ||
|
||
def __delitem__(self, key: str) -> None: | ||
del self.additional_properties[key] | ||
|
||
def __contains__(self, key: str) -> bool: | ||
return key in self.additional_properties |
Oops, something went wrong.