Skip to content

Commit

Permalink
feat: audio url
Browse files Browse the repository at this point in the history
  • Loading branch information
Chkhikvadze committed Nov 3, 2023
1 parent bb235a6 commit 27725ab
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion apps/server/models/chat_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ class ChatMessage(BaseModel):
UUID, ForeignKey("run.id", ondelete="CASCADE"), nullable=True, index=True
)

audio_url = Column(String(500), default=None, nullable=True)

message = Column(JSONB, nullable=False)
thoughts = Column(JSONB)
sender_name = Column(String, nullable=True)
sender_name = Column(
String,
nullable=True,
)

parent = relationship("ChatMessage", remote_side=[id], cascade="all, delete")
agent = relationship("AgentModel", back_populates="chat_messages")
Expand Down Expand Up @@ -82,6 +87,28 @@ def get_chat_message_by_id(cls, db, chat_message_id: UUID, account: AccountOutpu

return chat_message

@staticmethod
def update_audio_url_by_id(db, chat_message_id: UUID, new_audio_url: str):
"""
Retrieve a ChatMessage by its ID and update the audio_url.
Args:
db: The database session.
chat_message_id(UUID): The ID of the ChatMessage to be updated.
new_audio_url(str): The new audio_url to be updated.
Returns:
None
"""
chat_message = (
db.session.query(ChatMessage)
.filter(ChatMessage.id == chat_message_id)
.first()
)
if chat_message:
chat_message.audio_url = new_audio_url
db.session.commit()

def to_dict(self):
"""
Converts the current SQLAlchemy ORM object to a dictionary representation.
Expand Down

0 comments on commit 27725ab

Please sign in to comment.