Skip to content

Commit

Permalink
feat: migrated to Attachment from DIAL SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
adubovik committed Nov 29, 2024
1 parent ad77191 commit f15bb2d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
13 changes: 2 additions & 11 deletions aidial_adapter_bedrock/llm/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from typing import Optional, assert_never

from aidial_sdk.chat_completion import (
Attachment,
Choice,
FinishReason,
FunctionCall,
Response,
ToolCall,
)
from pydantic import BaseModel

from aidial_adapter_bedrock.dial_api.token_usage import TokenUsage
from aidial_adapter_bedrock.llm.message import (
Expand All @@ -20,15 +20,6 @@
from aidial_adapter_bedrock.llm.truncate_prompt import DiscardedMessages


class Attachment(BaseModel):
type: str | None = None
title: str | None = None
data: str | None = None
url: str | None = None
reference_url: str | None = None
reference_type: str | None = None


class Consumer(ABC):
@abstractmethod
def append_content(self, content: str):
Expand Down Expand Up @@ -147,7 +138,7 @@ def append_content(self, content: str):
self._process_content(content)

def add_attachment(self, attachment: Attachment):
self.choice.add_attachment(**attachment.dict())
self.choice.add_attachment(attachment)

def add_usage(self, usage: TokenUsage):
self.usage.accumulate(usage)
Expand Down
3 changes: 2 additions & 1 deletion aidial_adapter_bedrock/llm/model/stability/v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum
from typing import Any, Dict, List, Optional

from aidial_sdk.chat_completion import Attachment
from pydantic import BaseModel, Field

from aidial_adapter_bedrock.bedrock import Bedrock
Expand All @@ -14,7 +15,7 @@
TextCompletionAdapter,
TextCompletionPrompt,
)
from aidial_adapter_bedrock.llm.consumer import Attachment, Consumer
from aidial_adapter_bedrock.llm.consumer import Consumer
from aidial_adapter_bedrock.llm.errors import ValidationError
from aidial_adapter_bedrock.llm.message import BaseMessage
from aidial_adapter_bedrock.llm.model.stability.storage import save_to_storage
Expand Down
3 changes: 2 additions & 1 deletion aidial_adapter_bedrock/llm/model/stability/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List, Optional, Tuple, assert_never

from aidial_sdk.chat_completion import (
Attachment,
Message,
MessageContentImagePart,
MessageContentTextPart,
Expand All @@ -26,7 +27,7 @@
)
from aidial_adapter_bedrock.dial_api.token_usage import TokenUsage
from aidial_adapter_bedrock.llm.chat_model import ChatCompletionAdapter
from aidial_adapter_bedrock.llm.consumer import Attachment, Consumer
from aidial_adapter_bedrock.llm.consumer import Consumer
from aidial_adapter_bedrock.llm.errors import UserError, ValidationError
from aidial_adapter_bedrock.llm.model.stability.storage import save_to_storage
from aidial_adapter_bedrock.llm.truncate_prompt import DiscardedMessages
Expand Down

0 comments on commit f15bb2d

Please sign in to comment.