-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat/Enable file upload in chat window (#187)
* feat: Add file uploader in chat interface. * chore: Add manage documents for chat uploads. * feat: Create thread space for thread uploads. * fix: 'Empty Response' for consercutive shared asks. * chore: Setup spaces table DB migration script. * chore: Create a new layout for document lists. * refactor(UI): move "New chat" button to the bottom of the screen. * refactor(UI): Add a spinner when indexing thread space. * bump version v0.7.4 -> v0.7.5 --------- Co-authored-by: Janaka Abeywardhana <[email protected]>
- Loading branch information
Showing
21 changed files
with
607 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "docq" | ||
version = "0.7.4" | ||
version = "0.7.5" | ||
description = "Docq.AI - private and secure knowledge insight on your data." | ||
authors = ["Docq.AI Team <[email protected]>"] | ||
maintainers = ["Docq.AI Team <[email protected]>"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
"""Database migration scripts for schema changes etc.""" | ||
|
||
import logging | ||
import sqlite3 | ||
from contextlib import closing | ||
|
||
from opentelemetry import trace | ||
|
||
import docq | ||
from docq.support.store import SpaceType, get_sqlite_system_file | ||
|
||
tracer = trace.get_tracer(__name__, docq.__version_str__) | ||
|
||
|
||
@tracer.start_as_current_span("db_migrations.run") | ||
def run() -> None: | ||
"""Run database migrations. | ||
Call this after all tables are created. | ||
""" | ||
migration_sample1() | ||
add_space_type_to_spaces_table() | ||
|
||
|
||
def migration_sample1() -> None: | ||
"""Sample migration script.""" | ||
with tracer.start_as_current_span("migration_sample") as span: | ||
try: | ||
logging.info("Running migration sample") | ||
span.add_event("Running migration sample") | ||
# do some migration work | ||
logging.info("Migration sample complete successfully") | ||
span.set_attribute("migration_successful", "true") | ||
except Exception as e: | ||
logging.error("Migration XYZ sample failed") | ||
span.set_status(trace.Status(trace.StatusCode.ERROR, "Migration sample failed")) | ||
span.record_exception(e) | ||
raise Exception("Migration XYZ failed") from e | ||
|
||
|
||
def add_space_type_to_spaces_table() -> None: | ||
"""Add space_type column to spaces table. | ||
Check if space_type column exists in spaces table. if exists log and return. | ||
Create space_type column in spaces table with parameter space_type TEXT NOT NULL. | ||
UPDATE spaces SET space_type = SpaceType.SHARED.name for all existing rows. | ||
""" | ||
with tracer.start_as_current_span("add_space_type_to_spaces_table") as span: | ||
try: | ||
span.add_event("Running migration add_space_type_to_spaces_table") | ||
logging.info("Running migration add_space_type_to_spaces_table") | ||
|
||
with closing(sqlite3.connect(get_sqlite_system_file())) as connection, closing(connection.cursor()) as cursor: | ||
cursor.execute("SELECT name FROM pragma_table_info('spaces') WHERE name = 'space_type'") | ||
|
||
if cursor.fetchone() is None: | ||
logging.info("db_migrations.add_space_type_to_spaces_table, space_type column does not exist, adding it") | ||
span.add_event("space_type column does not exist, adding it") | ||
try: | ||
cursor.execute("BEGIN TRANSACTION") | ||
cursor.execute("ALTER TABLE spaces ADD COLUMN space_type TEXT NOT NULL DEFAULT '" + SpaceType.SHARED.name + "'",) | ||
connection.commit() | ||
logging.info("db_migrations.add_space_type_to_spaces_table, space_type column added successfully") | ||
span.add_event("space_type column added successfully") | ||
span.set_attribute("migration_successful", "true") | ||
|
||
except sqlite3.Error as e: | ||
logging.error("db_migrations.add_space_type_to_spaces_table, failed to add space_type column to spaces table %s", e) | ||
span.set_status(trace.Status(trace.StatusCode.ERROR, "Migration add_space_type_to_spaces_table failed")) | ||
span.set_attribute("migration_successful", "false") | ||
span.record_exception(e) | ||
connection.rollback() | ||
|
||
except Exception as e: | ||
logging.error("Migration add_space_type_to_spaces_table failed") | ||
span.set_status(trace.Status(trace.StatusCode.ERROR, "Migration add_space_type_to_spaces_table failed")) | ||
span.record_exception(e) | ||
raise Exception("Migration add_space_type_to_spaces_table failed") from e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.