Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[promptsv2] Can't instantiate abstract class BaseArtifact without an implementation for abstract methods #21

Open
MorganaDiasRodrigues opened this issue Aug 16, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@MorganaDiasRodrigues
Copy link

MorganaDiasRodrigues commented Aug 16, 2024

Original message error: TypeError: Can't instantiate abstract class BaseArtifact without an implementation for abstract methods 'get_referenced_variables', 'render'

branch: prompts2

Problem: When trying to send a prompt in the endpoint after creating the following schema and model, the API returns the warning about abstract methods.

schema.py

from abc import abstractmethod

class TextArtifact(BaseModel):
    """
    Artifact for textual inputs.
    """
    content: str
    content_encoding: str = "utf-8"
    type: str = "text"
    
    @abstractmethod
    def abst_def():
        pass

model.py

from datetime import UTC, datetime  # noqa: I001
from typing import Optional

from beanie import Document, Indexed

from .schemas import TextArtifact


class ChatCompletionModel(Document):
    """
    Chat completion model for CRUD operations.
    """
    chat_completion: TextArtifact
    name: Indexed(str)
    created_at: datetime
    updated_at: datetime = datetime.now(UTC)
    type: str = "chat_message"
    role: str
    sender_name: Optional[str] = None
    render: dict
    prompt: str

    def get_referenced_variables(self):
        """
        Doc.
        """
        print('get_red method')

    def render(self):
        """
        Doc
        """
        print('render method')

@MorganaDiasRodrigues MorganaDiasRodrigues added the bug Something isn't working label Aug 16, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant