Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/models/requests.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Model for service requests."""
"""Models for REST API requests."""

from typing import Optional, Self
from enum import Enum
Expand All @@ -13,17 +13,17 @@


class Attachment(BaseModel):
"""Model representing an attachment that can be send from UI as part of query.
"""Model representing an attachment that can be send from the UI as part of query.

List of attachments can be optional part of 'query' request.
A list of attachments can be an optional part of 'query' request.

Attributes:
attachment_type: The attachment type, like "log", "configuration" etc.
content_type: The content type as defined in MIME standard
content: The actual attachment content

YAML attachments with **kind** and **metadata/name** attributes will
be handled as resources with specified name:
be handled as resources with the specified name:
```
kind: Pod
metadata:
Expand All @@ -40,7 +40,8 @@ class Attachment(BaseModel):
examples=["text/plain"],
)
content: str = Field(
description="The actual attachment content", examples=["warning: quota exceed"]
description="The actual attachment content",
examples=["warning: quota exceeded"],
)

# provides examples for /docs endpoint
Expand Down Expand Up @@ -212,7 +213,7 @@ def validate_provider_and_model(self) -> Self:

@model_validator(mode="after")
def validate_media_type(self) -> Self:
"""Log use of media_type that is unsupported but kept for backwards compatibility."""
"""Log use of media_type that is unsupported but kept for backward compatibility."""
if self.media_type:
logger.warning(
"media_type was set in the request but is not supported. The value will be ignored."
Expand Down
24 changes: 15 additions & 9 deletions src/models/responses.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Models for service responses."""
"""Models for REST API responses."""

from typing import Any, Optional

Expand Down Expand Up @@ -80,7 +80,7 @@ class QueryResponse(BaseModel):


class InfoResponse(BaseModel):
"""Model representing a response to a info request.
"""Model representing a response to an info request.

Attributes:
name: Service name.
Expand Down Expand Up @@ -451,16 +451,18 @@ class ConversationDetails(BaseModel):
created_at: When the conversation was created.
last_message_at: When the last message was sent.
message_count: Number of user messages in the conversation.
model: The model used for the conversation.
last_used_model: The last model used for the conversation.
last_used_provider: The provider of the last used model.

Example:
```python
conversation = ConversationSummary(
conversation = ConversationDetails(
conversation_id="123e4567-e89b-12d3-a456-426614174000"
created_at="2024-01-01T00:00:00Z",
last_message_at="2024-01-01T00:05:00Z",
message_count=5,
model="gemini/gemini-2.0-flash"
last_used_model="gemini/gemini-2.0-flash",
last_used_provider="gemini",
)
```
"""
Expand Down Expand Up @@ -488,13 +490,15 @@ class ConversationsListResponse(BaseModel):
created_at="2024-01-01T00:00:00Z",
last_message_at="2024-01-01T00:05:00Z",
message_count=5,
model="gemini/gemini-2.0-flash"
last_used_model="gemini/gemini-2.0-flash",
last_used_provider="gemini",
),
ConversationDetails(
conversation_id="456e7890-e12b-34d5-a678-901234567890"
created_at="2024-01-01T01:00:00Z",
message_count=2,
model="gemini/gemini-2.5-flash"
last_used_model="gemini/gemini-2.0-flash",
last_used_provider="gemini",
)
]
)
Expand All @@ -514,13 +518,15 @@ class ConversationsListResponse(BaseModel):
"created_at": "2024-01-01T00:00:00Z",
"last_message_at": "2024-01-01T00:05:00Z",
"message_count": 5,
"model": "gemini/gemini-2.0-flash",
"last_used_model": "gemini/gemini-2.0-flash",
"last_used_provider": "gemini",
},
{
"conversation_id": "456e7890-e12b-34d5-a678-901234567890",
"created_at": "2024-01-01T01:00:00Z",
"message_count": 2,
"model": "gemini/gemini-2.5-flash",
"last_used_model": "gemini/gemini-2.5-flash",
"last_used_provider": "gemini",
},
]
}
Expand Down