feat: update tabby-python-client
parent
5cd32eb7c0
commit
aacfd35464
|
|
@ -7,7 +7,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="tabby-python-client",
|
name="tabby-python-client",
|
||||||
version="0.1.0",
|
version="0.3.0",
|
||||||
description="A client library for accessing Tabby Server",
|
description="A client library for accessing Tabby Server",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ def _get_kwargs(
|
||||||
cookies: Dict[str, Any] = client.get_cookies()
|
cookies: Dict[str, Any] = client.get_cookies()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"method": "post",
|
"method": "get",
|
||||||
"url": url,
|
"url": url,
|
||||||
"headers": headers,
|
"headers": headers,
|
||||||
"cookies": cookies,
|
"cookies": cookies,
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,33 @@
|
||||||
""" Contains all the data models used in inputs/outputs """
|
""" 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 .choice import Choice
|
||||||
from .completion_request import CompletionRequest
|
from .completion_request import CompletionRequest
|
||||||
from .completion_response import CompletionResponse
|
from .completion_response import CompletionResponse
|
||||||
from .health_state import HealthState
|
from .health_state import HealthState
|
||||||
|
from .hit import Hit
|
||||||
|
from .hit_document import HitDocument
|
||||||
from .log_event_request import LogEventRequest
|
from .log_event_request import LogEventRequest
|
||||||
|
from .message import Message
|
||||||
|
from .search_response import SearchResponse
|
||||||
from .segments import Segments
|
from .segments import Segments
|
||||||
|
from .snippet import Snippet
|
||||||
|
from .version import Version
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
"ChatCompletionChunk",
|
||||||
|
"ChatCompletionRequest",
|
||||||
"Choice",
|
"Choice",
|
||||||
"CompletionRequest",
|
"CompletionRequest",
|
||||||
"CompletionResponse",
|
"CompletionResponse",
|
||||||
"HealthState",
|
"HealthState",
|
||||||
|
"Hit",
|
||||||
|
"HitDocument",
|
||||||
"LogEventRequest",
|
"LogEventRequest",
|
||||||
|
"Message",
|
||||||
|
"SearchResponse",
|
||||||
"Segments",
|
"Segments",
|
||||||
|
"Snippet",
|
||||||
|
"Version",
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -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
|
||||||
|
|
@ -23,7 +23,9 @@ class CompletionRequest:
|
||||||
language (Union[Unset, None, str]): Language identifier, full list is maintained at
|
language (Union[Unset, None, str]): Language identifier, full list is maintained at
|
||||||
https://code.visualstudio.com/docs/languages/identifiers Example: python.
|
https://code.visualstudio.com/docs/languages/identifiers Example: python.
|
||||||
segments (Union[Unset, None, Segments]):
|
segments (Union[Unset, None, Segments]):
|
||||||
user (Union[Unset, None, str]):
|
user (Union[Unset, None, str]): A unique identifier representing your end-user, which can help Tabby to monitor
|
||||||
|
& generating
|
||||||
|
reports.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
prompt: Union[Unset, None, str] = UNSET
|
prompt: Union[Unset, None, str] = UNSET
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ T = TypeVar("T", bound="CompletionResponse")
|
||||||
@attr.s(auto_attribs=True)
|
@attr.s(auto_attribs=True)
|
||||||
class CompletionResponse:
|
class CompletionResponse:
|
||||||
"""
|
"""
|
||||||
|
Example:
|
||||||
|
{'choices': [{'index': 0, 'text': 'string'}], 'id': 'string'}
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
id (str):
|
id (str):
|
||||||
choices (List['Choice']):
|
choices (List['Choice']):
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
from typing import Any, Dict, List, Type, TypeVar
|
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar, Union, cast
|
||||||
|
|
||||||
import attr
|
import attr
|
||||||
|
|
||||||
|
from ..types import UNSET, Unset
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..models.version import Version
|
||||||
|
|
||||||
|
|
||||||
T = TypeVar("T", bound="HealthState")
|
T = TypeVar("T", bound="HealthState")
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -11,18 +17,35 @@ class HealthState:
|
||||||
Attributes:
|
Attributes:
|
||||||
model (str):
|
model (str):
|
||||||
device (str):
|
device (str):
|
||||||
compute_type (str):
|
arch (str):
|
||||||
|
cpu_info (str):
|
||||||
|
cpu_count (int):
|
||||||
|
cuda_devices (List[str]):
|
||||||
|
version (Version):
|
||||||
|
chat_model (Union[Unset, None, str]):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
model: str
|
model: str
|
||||||
device: str
|
device: str
|
||||||
compute_type: str
|
arch: str
|
||||||
|
cpu_info: str
|
||||||
|
cpu_count: int
|
||||||
|
cuda_devices: List[str]
|
||||||
|
version: "Version"
|
||||||
|
chat_model: Union[Unset, None, str] = UNSET
|
||||||
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
def to_dict(self) -> Dict[str, Any]:
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
model = self.model
|
model = self.model
|
||||||
device = self.device
|
device = self.device
|
||||||
compute_type = self.compute_type
|
arch = self.arch
|
||||||
|
cpu_info = self.cpu_info
|
||||||
|
cpu_count = self.cpu_count
|
||||||
|
cuda_devices = self.cuda_devices
|
||||||
|
|
||||||
|
version = self.version.to_dict()
|
||||||
|
|
||||||
|
chat_model = self.chat_model
|
||||||
|
|
||||||
field_dict: Dict[str, Any] = {}
|
field_dict: Dict[str, Any] = {}
|
||||||
field_dict.update(self.additional_properties)
|
field_dict.update(self.additional_properties)
|
||||||
|
|
@ -30,25 +53,48 @@ class HealthState:
|
||||||
{
|
{
|
||||||
"model": model,
|
"model": model,
|
||||||
"device": device,
|
"device": device,
|
||||||
"compute_type": compute_type,
|
"arch": arch,
|
||||||
|
"cpu_info": cpu_info,
|
||||||
|
"cpu_count": cpu_count,
|
||||||
|
"cuda_devices": cuda_devices,
|
||||||
|
"version": version,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
if chat_model is not UNSET:
|
||||||
|
field_dict["chat_model"] = chat_model
|
||||||
|
|
||||||
return field_dict
|
return field_dict
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
from ..models.version import Version
|
||||||
|
|
||||||
d = src_dict.copy()
|
d = src_dict.copy()
|
||||||
model = d.pop("model")
|
model = d.pop("model")
|
||||||
|
|
||||||
device = d.pop("device")
|
device = d.pop("device")
|
||||||
|
|
||||||
compute_type = d.pop("compute_type")
|
arch = d.pop("arch")
|
||||||
|
|
||||||
|
cpu_info = d.pop("cpu_info")
|
||||||
|
|
||||||
|
cpu_count = d.pop("cpu_count")
|
||||||
|
|
||||||
|
cuda_devices = cast(List[str], d.pop("cuda_devices"))
|
||||||
|
|
||||||
|
version = Version.from_dict(d.pop("version"))
|
||||||
|
|
||||||
|
chat_model = d.pop("chat_model", UNSET)
|
||||||
|
|
||||||
health_state = cls(
|
health_state = cls(
|
||||||
model=model,
|
model=model,
|
||||||
device=device,
|
device=device,
|
||||||
compute_type=compute_type,
|
arch=arch,
|
||||||
|
cpu_info=cpu_info,
|
||||||
|
cpu_count=cpu_count,
|
||||||
|
cuda_devices=cuda_devices,
|
||||||
|
version=version,
|
||||||
|
chat_model=chat_model,
|
||||||
)
|
)
|
||||||
|
|
||||||
health_state.additional_properties = d
|
health_state.additional_properties = d
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,92 @@
|
||||||
|
from typing import Any, Dict, List, Type, TypeVar
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
|
T = TypeVar("T", bound="HitDocument")
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s(auto_attribs=True)
|
||||||
|
class HitDocument:
|
||||||
|
"""
|
||||||
|
Attributes:
|
||||||
|
body (str):
|
||||||
|
filepath (str):
|
||||||
|
git_url (str):
|
||||||
|
kind (str):
|
||||||
|
language (str):
|
||||||
|
name (str):
|
||||||
|
"""
|
||||||
|
|
||||||
|
body: str
|
||||||
|
filepath: str
|
||||||
|
git_url: str
|
||||||
|
kind: str
|
||||||
|
language: str
|
||||||
|
name: str
|
||||||
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
body = self.body
|
||||||
|
filepath = self.filepath
|
||||||
|
git_url = self.git_url
|
||||||
|
kind = self.kind
|
||||||
|
language = self.language
|
||||||
|
name = self.name
|
||||||
|
|
||||||
|
field_dict: Dict[str, Any] = {}
|
||||||
|
field_dict.update(self.additional_properties)
|
||||||
|
field_dict.update(
|
||||||
|
{
|
||||||
|
"body": body,
|
||||||
|
"filepath": filepath,
|
||||||
|
"git_url": git_url,
|
||||||
|
"kind": kind,
|
||||||
|
"language": language,
|
||||||
|
"name": name,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return field_dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
d = src_dict.copy()
|
||||||
|
body = d.pop("body")
|
||||||
|
|
||||||
|
filepath = d.pop("filepath")
|
||||||
|
|
||||||
|
git_url = d.pop("git_url")
|
||||||
|
|
||||||
|
kind = d.pop("kind")
|
||||||
|
|
||||||
|
language = d.pop("language")
|
||||||
|
|
||||||
|
name = d.pop("name")
|
||||||
|
|
||||||
|
hit_document = cls(
|
||||||
|
body=body,
|
||||||
|
filepath=filepath,
|
||||||
|
git_url=git_url,
|
||||||
|
kind=kind,
|
||||||
|
language=language,
|
||||||
|
name=name,
|
||||||
|
)
|
||||||
|
|
||||||
|
hit_document.additional_properties = d
|
||||||
|
return hit_document
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
@ -0,0 +1,64 @@
|
||||||
|
from typing import Any, Dict, List, Type, TypeVar
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
|
T = TypeVar("T", bound="Message")
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s(auto_attribs=True)
|
||||||
|
class Message:
|
||||||
|
"""
|
||||||
|
Attributes:
|
||||||
|
role (str):
|
||||||
|
content (str):
|
||||||
|
"""
|
||||||
|
|
||||||
|
role: str
|
||||||
|
content: str
|
||||||
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
role = self.role
|
||||||
|
content = self.content
|
||||||
|
|
||||||
|
field_dict: Dict[str, Any] = {}
|
||||||
|
field_dict.update(self.additional_properties)
|
||||||
|
field_dict.update(
|
||||||
|
{
|
||||||
|
"role": role,
|
||||||
|
"content": content,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return field_dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
d = src_dict.copy()
|
||||||
|
role = d.pop("role")
|
||||||
|
|
||||||
|
content = d.pop("content")
|
||||||
|
|
||||||
|
message = cls(
|
||||||
|
role=role,
|
||||||
|
content=content,
|
||||||
|
)
|
||||||
|
|
||||||
|
message.additional_properties = d
|
||||||
|
return message
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
@ -0,0 +1,79 @@
|
||||||
|
from typing import TYPE_CHECKING, Any, Dict, List, Type, TypeVar
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from ..models.hit import Hit
|
||||||
|
|
||||||
|
|
||||||
|
T = TypeVar("T", bound="SearchResponse")
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s(auto_attribs=True)
|
||||||
|
class SearchResponse:
|
||||||
|
"""
|
||||||
|
Attributes:
|
||||||
|
num_hits (int):
|
||||||
|
hits (List['Hit']):
|
||||||
|
"""
|
||||||
|
|
||||||
|
num_hits: int
|
||||||
|
hits: List["Hit"]
|
||||||
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
num_hits = self.num_hits
|
||||||
|
hits = []
|
||||||
|
for hits_item_data in self.hits:
|
||||||
|
hits_item = hits_item_data.to_dict()
|
||||||
|
|
||||||
|
hits.append(hits_item)
|
||||||
|
|
||||||
|
field_dict: Dict[str, Any] = {}
|
||||||
|
field_dict.update(self.additional_properties)
|
||||||
|
field_dict.update(
|
||||||
|
{
|
||||||
|
"num_hits": num_hits,
|
||||||
|
"hits": hits,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return field_dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
from ..models.hit import Hit
|
||||||
|
|
||||||
|
d = src_dict.copy()
|
||||||
|
num_hits = d.pop("num_hits")
|
||||||
|
|
||||||
|
hits = []
|
||||||
|
_hits = d.pop("hits")
|
||||||
|
for hits_item_data in _hits:
|
||||||
|
hits_item = Hit.from_dict(hits_item_data)
|
||||||
|
|
||||||
|
hits.append(hits_item)
|
||||||
|
|
||||||
|
search_response = cls(
|
||||||
|
num_hits=num_hits,
|
||||||
|
hits=hits,
|
||||||
|
)
|
||||||
|
|
||||||
|
search_response.additional_properties = d
|
||||||
|
return search_response
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
from typing import Any, Dict, List, Type, TypeVar
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
|
T = TypeVar("T", bound="Snippet")
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s(auto_attribs=True)
|
||||||
|
class Snippet:
|
||||||
|
"""
|
||||||
|
Attributes:
|
||||||
|
filepath (str):
|
||||||
|
body (str):
|
||||||
|
score (float):
|
||||||
|
"""
|
||||||
|
|
||||||
|
filepath: str
|
||||||
|
body: str
|
||||||
|
score: float
|
||||||
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
filepath = self.filepath
|
||||||
|
body = self.body
|
||||||
|
score = self.score
|
||||||
|
|
||||||
|
field_dict: Dict[str, Any] = {}
|
||||||
|
field_dict.update(self.additional_properties)
|
||||||
|
field_dict.update(
|
||||||
|
{
|
||||||
|
"filepath": filepath,
|
||||||
|
"body": body,
|
||||||
|
"score": score,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return field_dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
d = src_dict.copy()
|
||||||
|
filepath = d.pop("filepath")
|
||||||
|
|
||||||
|
body = d.pop("body")
|
||||||
|
|
||||||
|
score = d.pop("score")
|
||||||
|
|
||||||
|
snippet = cls(
|
||||||
|
filepath=filepath,
|
||||||
|
body=body,
|
||||||
|
score=score,
|
||||||
|
)
|
||||||
|
|
||||||
|
snippet.additional_properties = d
|
||||||
|
return snippet
|
||||||
|
|
||||||
|
@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
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
from typing import Any, Dict, List, Type, TypeVar
|
||||||
|
|
||||||
|
import attr
|
||||||
|
|
||||||
|
T = TypeVar("T", bound="Version")
|
||||||
|
|
||||||
|
|
||||||
|
@attr.s(auto_attribs=True)
|
||||||
|
class Version:
|
||||||
|
"""
|
||||||
|
Attributes:
|
||||||
|
build_date (str):
|
||||||
|
build_timestamp (str):
|
||||||
|
git_sha (str):
|
||||||
|
git_describe (str):
|
||||||
|
"""
|
||||||
|
|
||||||
|
build_date: str
|
||||||
|
build_timestamp: str
|
||||||
|
git_sha: str
|
||||||
|
git_describe: str
|
||||||
|
additional_properties: Dict[str, Any] = attr.ib(init=False, factory=dict)
|
||||||
|
|
||||||
|
def to_dict(self) -> Dict[str, Any]:
|
||||||
|
build_date = self.build_date
|
||||||
|
build_timestamp = self.build_timestamp
|
||||||
|
git_sha = self.git_sha
|
||||||
|
git_describe = self.git_describe
|
||||||
|
|
||||||
|
field_dict: Dict[str, Any] = {}
|
||||||
|
field_dict.update(self.additional_properties)
|
||||||
|
field_dict.update(
|
||||||
|
{
|
||||||
|
"build_date": build_date,
|
||||||
|
"build_timestamp": build_timestamp,
|
||||||
|
"git_sha": git_sha,
|
||||||
|
"git_describe": git_describe,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return field_dict
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_dict(cls: Type[T], src_dict: Dict[str, Any]) -> T:
|
||||||
|
d = src_dict.copy()
|
||||||
|
build_date = d.pop("build_date")
|
||||||
|
|
||||||
|
build_timestamp = d.pop("build_timestamp")
|
||||||
|
|
||||||
|
git_sha = d.pop("git_sha")
|
||||||
|
|
||||||
|
git_describe = d.pop("git_describe")
|
||||||
|
|
||||||
|
version = cls(
|
||||||
|
build_date=build_date,
|
||||||
|
build_timestamp=build_timestamp,
|
||||||
|
git_sha=git_sha,
|
||||||
|
git_describe=git_describe,
|
||||||
|
)
|
||||||
|
|
||||||
|
version.additional_properties = d
|
||||||
|
return version
|
||||||
|
|
||||||
|
@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
|
||||||
Loading…
Reference in New Issue