-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from ggozad/feat/save-images-in-messages
Persist images in message history / sqlite db.
- Loading branch information
Showing
8 changed files
with
115 additions
and
40 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
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 @@ | ||
[project] | ||
name = "oterm" | ||
version = "0.6.9" | ||
version = "0.7.0" | ||
description = "A text-based terminal client for Ollama." | ||
authors = [{ name = "Yiorgis Gozadinos", email = "[email protected]" }] | ||
license = { text = "MIT" } | ||
|
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,37 @@ | ||
from pathlib import Path | ||
from typing import Awaitable, Callable | ||
|
||
import aiosqlite | ||
|
||
|
||
async def images(db_path: Path) -> None: | ||
async with aiosqlite.connect(db_path) as connection: | ||
try: | ||
await connection.executescript( | ||
""" | ||
ALTER TABLE message ADD COLUMN images TEXT DEFAULT "[]"; | ||
""" | ||
) | ||
except aiosqlite.OperationalError: | ||
pass | ||
|
||
await connection.commit() | ||
|
||
|
||
async def orphan_messages(db_path: Path) -> None: | ||
async with aiosqlite.connect(db_path) as connection: | ||
try: | ||
await connection.executescript( | ||
""" | ||
DELETE FROM message WHERE chat_id NOT IN (SELECT id FROM chat); | ||
""" | ||
) | ||
except aiosqlite.OperationalError: | ||
pass | ||
|
||
await connection.commit() | ||
|
||
|
||
upgrades: list[tuple[str, list[Callable[[Path], Awaitable[None]]]]] = [ | ||
("0.7.0", [images, orphan_messages]), | ||
] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.