mirror of
https://github.com/furyhawk/agent_alpha.git
synced 2026-07-21 02:25:34 +00:00
feat: Add session commit in database operations and update embedding configuration
This commit is contained in:
@@ -99,6 +99,7 @@ def open_session() -> AsyncSession:
|
||||
|
||||
async with open_session() as session:
|
||||
await session.execute(...)
|
||||
await session.commit() # required — no auto-commit
|
||||
|
||||
The session is automatically closed on exit of the ``async with`` block.
|
||||
"""
|
||||
|
||||
@@ -98,14 +98,18 @@ EMBEDDING_DIMENSIONS: dict[str, int] = {
|
||||
"bge-small-en-v1.5": 384,
|
||||
"bge-base-en-v1.5": 768,
|
||||
"bge-large-en-v1.5": 1024,
|
||||
# llama.cpp / local models (Gemma, Llama, etc.)
|
||||
"gemma-4-12b-it": 3840,
|
||||
"gemma-4-12b": 3840,
|
||||
"unsloth/gemma-4-12B-it-qat-GGUF:UD-Q4_K_XL": 3840,
|
||||
}
|
||||
|
||||
|
||||
class EmbeddingsConfig(BaseModel):
|
||||
"""Embeddings configuration. Dimension is auto-derived from model name."""
|
||||
|
||||
model: str = "text-embedding-3-small"
|
||||
dim: int = 1536
|
||||
model: str = "unsloth/gemma-4-12B-it-qat-GGUF:UD-Q4_K_XL"
|
||||
dim: int = 3840
|
||||
|
||||
@model_validator(mode="after")
|
||||
def set_dim_from_model(self) -> "EmbeddingsConfig":
|
||||
|
||||
@@ -86,6 +86,7 @@ async def ingest_document_task(
|
||||
doc_id=rag_document_id,
|
||||
error_message=result.error_message or "Unknown error",
|
||||
)
|
||||
await session.commit()
|
||||
|
||||
logger.info(
|
||||
"[WORKER] Ingestion complete: doc=%s, status=%s",
|
||||
@@ -104,6 +105,7 @@ async def ingest_document_task(
|
||||
doc_id=rag_document_id,
|
||||
error_message=str(exc),
|
||||
)
|
||||
await session.commit()
|
||||
return {"status": "error", "message": str(exc)}
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ services:
|
||||
- MAX_UPLOAD_SIZE_MB=${MAX_UPLOAD_SIZE_MB:-50}
|
||||
# Embeddings — defaults to LLM_BASE_URL; set to a server that supports
|
||||
# the OpenAI-compatible embeddings endpoint (e.g. Ollama, OpenAI).
|
||||
- EMBEDDING_BASE_URL=${EMBEDDING_BASE_URL:-}
|
||||
- EMBEDDING_BASE_URL=${EMBEDDING_BASE_URL:-http://host.containers.internal:8011/v1}
|
||||
- EMBEDDING_API_KEY=${EMBEDDING_API_KEY:-}
|
||||
|
||||
restart: unless-stopped
|
||||
|
||||
Reference in New Issue
Block a user