Skip to content

Commit

Permalink
Add inference backend support for data opt out (#2820)
Browse files Browse the repository at this point in the history
Currently there is no functionality to change as we don't have a
mechanism of exporting chats.
  • Loading branch information
olliestanley committed Apr 29, 2023
1 parent fd55e6c commit ece0384
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
@@ -0,0 +1,27 @@
"""Add chat data opt out field
Revision ID: 401eef162771
Revises: b66fd8f9da1f
Create Date: 2023-04-24 21:30:19.947411
"""
import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "401eef162771"
down_revision = "b66fd8f9da1f"
branch_labels = None
depends_on = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("chat", sa.Column("allow_data_use", sa.Boolean(), server_default=sa.text("true"), nullable=False))
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("chat", "allow_data_use")
# ### end Alembic commands ###
2 changes: 2 additions & 0 deletions inference/server/oasst_inference_server/models/chat.py
Expand Up @@ -76,6 +76,8 @@ class DbChat(SQLModel, table=True):

hidden: bool = Field(False, sa_column=sa.Column(sa.Boolean, nullable=False, server_default=sa.false()))

allow_data_use: bool = Field(True, sa_column=sa.Column(sa.Boolean, nullable=False, server_default=sa.true()))

def to_list_read(self) -> chat_schema.ChatListRead:
return chat_schema.ChatListRead(
id=self.id,
Expand Down
1 change: 1 addition & 0 deletions inference/server/oasst_inference_server/routes/chats.py
Expand Up @@ -311,6 +311,7 @@ async def handle_update_chat(
chat_id=chat_id,
title=request.title,
hidden=request.hidden,
allow_data_use=request.allow_data_use,
)
except Exception:
logger.exception("Error when updating chat")
Expand Down
1 change: 1 addition & 0 deletions inference/server/oasst_inference_server/schemas/chat.py
Expand Up @@ -89,3 +89,4 @@ def __init__(self, message: inference.MessageRead):
class ChatUpdateRequest(pydantic.BaseModel):
title: pydantic.constr(max_length=100) | None = None
hidden: bool | None = None
allow_data_use: bool | None = None
Expand Up @@ -275,6 +275,7 @@ async def update_chat(
chat_id: str,
title: str | None = None,
hidden: bool | None = None,
allow_data_use: bool | None = None,
) -> None:
logger.info(f"Updating chat {chat_id=}: {title=} {hidden=}")
chat = await self.get_chat_by_id(chat_id=chat_id, include_messages=False)
Expand All @@ -287,4 +288,8 @@ async def update_chat(
logger.info(f"Setting chat {chat_id=} to {'hidden' if hidden else 'visible'}")
chat.hidden = hidden

if allow_data_use is not None:
logger.info(f"Updating allow_data_use of chat {chat_id=}: {allow_data_use=}")
chat.allow_data_use = allow_data_use

await self.session.commit()

0 comments on commit ece0384

Please sign in to comment.