Template
ChatCompletionChoice
Bases: BaseModel
A single completion choice from the model.
Attributes:
| Name | Type | Description |
|---|---|---|
index |
int
|
The index of this choice in the list of choices. |
message |
ChatCompletionMessage
|
The generated message for this choice. |
finish_reason |
str
|
The reason why the model stopped generating. |
Source code in pita/api/api_template.py
80 81 82 83 84 85 86 87 88 89 90 91 | |
ChatCompletionMessage
Bases: BaseModel
A single message in a chat conversation.
Attributes:
| Name | Type | Description |
|---|---|---|
role |
ChatMessageRole
|
The role of the message sender (system, user, or assistant). |
content |
str
|
The text content of the message. |
name |
Optional[str]
|
Optional name of the message author. |
Source code in pita/api/api_template.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
ChatCompletionRequest
Bases: BaseModel
Request model for chat completion API endpoint.
This model defines all parameters that can be sent when requesting a chat completion, following the OpenAI-compatible API format.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
Name of the model to use for completion. |
messages |
List[ChatCompletionMessage]
|
List of messages in chat format (conversation history). |
max_tokens |
Optional[int]
|
Maximum number of new tokens to generate. |
temperature |
Optional[float]
|
Sampling temperature. Higher values make output more random. |
top_p |
Optional[float]
|
Nucleus sampling parameter. |
n |
Optional[int]
|
Number of completions to generate for each prompt. |
stream |
Optional[bool]
|
Whether to stream responses incrementally. |
stop |
Optional[List[str]]
|
List of sequences where the API will stop generating. |
presence_penalty |
Optional[float]
|
Penalty for tokens based on their presence in the text so far. |
frequency_penalty |
Optional[float]
|
Penalty for tokens based on their frequency in the text so far. |
logit_bias |
Optional[Dict[str, int]]
|
Map of token IDs to bias values. |
user |
Optional[str]
|
Optional unique identifier for the end-user. |
Source code in pita/api/api_template.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
ChatCompletionResponse
Bases: BaseModel
Response model for chat completion API endpoint.
This model defines the structure of the response returned by the chat completion endpoint, following the OpenAI-compatible API format.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
Unique identifier for this completion. |
object |
str
|
Object type (always "chat.completion" for non-streaming). |
created |
int
|
Unix timestamp of when the completion was created. |
model |
str
|
The model used for this completion. |
choices |
List[ChatCompletionChoice]
|
List of completion choices (typically one unless n > 1 in request). |
usage |
Usage
|
Token usage statistics for this request. |
Source code in pita/api/api_template.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
ChatMessageRole
Bases: str, Enum
Enumeration of possible roles for chat messages.
Values
System: System message role for instructions. User: User message role for user inputs. Assistant: Assistant message role for AI responses.
Source code in pita/api/api_template.py
20 21 22 23 24 25 26 27 28 29 30 31 | |
Usage
Bases: BaseModel
Token usage statistics for API requests and responses.
Attributes:
| Name | Type | Description |
|---|---|---|
prompt_tokens |
int
|
Number of tokens in the prompt/input. |
completion_tokens |
int
|
Number of tokens in the completion/output. |
total_tokens |
int
|
Total number of tokens (prompt + completion). |
Source code in pita/api/api_template.py
6 7 8 9 10 11 12 13 14 15 16 17 | |