diff --git a/lib/galaxy/model/__init__.py b/lib/galaxy/model/__init__.py index 515bcffb28e4..18b0ba2e6831 100644 --- a/lib/galaxy/model/__init__.py +++ b/lib/galaxy/model/__init__.py @@ -11543,8 +11543,8 @@ class ChatGXYResponses(Base): __tablename__ = "chatgxy_responses" id: Mapped[int] = mapped_column(primary_key=True) - job_id: Mapped[Optional[int]] = mapped_column(ForeignKey("job.id"), nullable=True) - response: Mapped[str] = mapped_column(TEXT, nullable=True) + job_id: Mapped[Optional[int]] = mapped_column(ForeignKey("job.id"), index=True) + response: Mapped[str] = mapped_column(TEXT, nullable=False) feedback: Mapped[int] = mapped_column(Integer, nullable=True) diff --git a/lib/galaxy/model/migrations/alembic/versions_gxy/8067ed6a55e7_create_chatgxy_table.py b/lib/galaxy/model/migrations/alembic/versions_gxy/8067ed6a55e7_create_chatgxy_table.py index ca68b3b02ab6..1ecb5ea9f380 100644 --- a/lib/galaxy/model/migrations/alembic/versions_gxy/8067ed6a55e7_create_chatgxy_table.py +++ b/lib/galaxy/model/migrations/alembic/versions_gxy/8067ed6a55e7_create_chatgxy_table.py @@ -30,7 +30,7 @@ def upgrade(): create_table( table_name, Column('id', Integer, primary_key=True), - Column('job_id', Integer, ForeignKey('job.id'), nullable=True), + Column('job_id', Integer, ForeignKey('job.id'), index=True), Column('response', Text, nullable=False), Column('feedback', Integer, nullable=True), ) diff --git a/lib/galaxy/webapps/galaxy/api/chat.py b/lib/galaxy/webapps/galaxy/api/chat.py index 07792eb64369..08cadff2612f 100644 --- a/lib/galaxy/webapps/galaxy/api/chat.py +++ b/lib/galaxy/webapps/galaxy/api/chat.py @@ -42,6 +42,9 @@ def query(self, query: ChatPayload, trans: ProvidesUserContext = DependsOnTrans) response = self._call_openai(messages) answer = response.choices[0].message.content + + # save the answer to the database under chatgxy_responses table + return answer def _ensure_openai_configured(self):