Skip to content

Commit

Permalink
appease mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
blakerosenthal committed Jun 13, 2024
1 parent a17fd56 commit 6011a4f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 1 addition & 3 deletions ragna/deploy/_api/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ def schema_to_core_chat(
chat_name=chat.metadata.name,
**chat.metadata.params,
)
core_chat._messages = [
message.to_core() for message in chat.messages
]
core_chat._messages = [message.to_core() for message in chat.messages]
core_chat._prepared = chat.prepared

return core_chat
Expand Down
26 changes: 14 additions & 12 deletions ragna/deploy/_api/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def from_core(cls, document: ragna.core.Document) -> Document:
name=document.name,
)

@classmethod
def to_core(cls, document: Document) -> ragna.core.Document:
return ragna.core.Document(
id=document.id,
name=document.name,
def to_core(self) -> ragna.core.Document:
return ragna.core.LocalDocument(
id=self.id,
name=self.name,
# TEMP: setting an empty metadata dict for now.
# Will be resolved as part of the "managed ragna" work:
# https://github.com/Quansight/ragna/issues/256
metadata={},
)


Expand All @@ -57,14 +60,13 @@ def from_core(cls, source: ragna.core.Source) -> Source:
num_tokens=source.num_tokens,
)

@classmethod
def to_core(cls, source: Source) -> ragna.core.Source:
def to_core(self) -> ragna.core.Source:
return ragna.core.Source(
id=source.id,
document=Document.to_core(source.document),
location=source.location,
content=source.content,
num_tokens=source.num_tokens,
id=self.id,
document=self.document.to_core(),
location=self.location,
content=self.content,
num_tokens=self.num_tokens,
)


Expand Down

0 comments on commit 6011a4f

Please sign in to comment.