Merge branch 'main' of github.com:LAION-AI/Open-Chat-GPT

This commit is contained in:
Yannic Kilcher
2022-12-17 23:23:18 +01:00
3 changed files with 38 additions and 1 deletions
@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
"""add auth_method to person
Revision ID: 6368515778c5
Revises: cd7de470586e
Create Date: 2022-12-17 17:57:33.022549
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "6368515778c5"
down_revision = "cd7de470586e"
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("person", sa.Column("auth_method", sa.String(length=128), nullable=True))
op.execute("UPDATE person SET auth_method = 'local'")
op.alter_column("person", "auth_method", nullable=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("person", "auth_method")
# ### end Alembic commands ###
+1
View File
@@ -18,6 +18,7 @@ class Person(SQLModel, table=True):
),
)
username: str = Field(nullable=False, max_length=128)
auth_method: str = Field(nullable=False, max_length=128, default="local")
display_name: str = Field(nullable=False, max_length=256)
created_date: Optional[datetime] = Field(
sa_column=sa.Column(sa.DateTime(), nullable=False, server_default=sa.func.current_timestamp())
+7 -1
View File
@@ -22,7 +22,13 @@ class PromptRepository:
if not user:
return None
person: Person = (
self.db.query(Person).filter(Person.api_client_id == self.api_client.id, Person.username == user.id).first()
self.db.query(Person)
.filter(
Person.api_client_id == self.api_client.id,
Person.username == user.id,
Person.auth_method == user.auth_method,
)
.first()
)
if person is None:
# user is unknown, create new record