Update manual add
This commit is contained in:
parent
5593d802b3
commit
426aa670fa
1 changed files with 21 additions and 2 deletions
19
handlers.py
19
handlers.py
|
|
@ -420,16 +420,35 @@ def handle_add_manual_submit(body):
|
|||
db = get_db()
|
||||
try:
|
||||
now = __import__("datetime").datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
|
||||
|
||||
# Insert the page
|
||||
db.execute(
|
||||
"INSERT INTO pages (url, title, body, note, last_modified, summary) VALUES (?, ?, ?, ?, ?, ?) "
|
||||
"ON CONFLICT(url) DO UPDATE SET title=excluded.title, body=excluded.body, "
|
||||
"note=excluded.note, last_modified=excluded.last_modified, summary=excluded.summary",
|
||||
(url, manual_title, manual_desc, note, now, manual_desc[:200]),
|
||||
)
|
||||
|
||||
# Get the page ID
|
||||
page_id = db.execute("SELECT id FROM pages WHERE url = ?", (url,)).fetchone()[0]
|
||||
|
||||
# Add tags if provided
|
||||
if tags:
|
||||
_set_page_tags(page_id, tags, db)
|
||||
|
||||
db.commit()
|
||||
|
||||
# Generate embeddings for this page (if semantic search is enabled)
|
||||
if get_setting("semantic_search", "1") == "1":
|
||||
try:
|
||||
from embeddings import store_embeddings
|
||||
# Pass the page_id, title, description, and db connection
|
||||
store_embeddings(page_id, manual_title, manual_desc, db)
|
||||
db.commit()
|
||||
except Exception as e:
|
||||
# Log error but don't fail the whole operation
|
||||
print(f"Error generating embeddings: {e}")
|
||||
|
||||
return handle_add_form(f'Added manually: <a href="{esc(url)}">{esc(manual_title)}</a>')
|
||||
finally:
|
||||
return_db(db)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue