Summary
locus.rag.embeddings.oci.OCIEmbeddings.embed_query() (around line 370 in 0.2.0b25) hardcodes input_type="SEARCH_QUERY" on the underlying EmbedTextDetails request, ignoring self.oci_config.input_type.
For cohere.embed-v4.0 on OCI Generative AI, the two input_types return different output dimensions:
| input_type |
output dim |
SEARCH_DOCUMENT |
1536 |
SEARCH_QUERY |
1024 |
(This asymmetry is OCI/Cohere v4 behaviour, not Locus's fault — but it interacts badly with the hardcoded override.)
embed_documents() correctly uses SEARCH_DOCUMENT, so an ingestion path that calls embed_documents populates a vector column at 1536 dim. Then a search via embed_query returns a 1024-dim vector. VECTOR_DISTANCE(embedding /*1536*/, :qvec /*1024*/, COSINE) raises:
ORA-12801: error signaled in parallel query server P000, instance 1
ORA-51803: Vector dimension count must match the dimension count
specified in the column definition (expected 1536 dimensions,
specified 1024 dimensions).
Net result: every RAG query against a v4-indexed table errors out, with no warning at config / startup time.
Reproduction
import asyncio
from locus.rag import OCIEmbeddings, OracleVectorStore, RAGRetriever
from locus.rag.embeddings.oci import OCIEmbeddingConfig
async def main():
e = OCIEmbeddings(
oci_config=OCIEmbeddingConfig(
model_id="cohere.embed-v4.0",
compartment_id="…",
profile_name="DEFAULT",
input_type="SEARCH_DOCUMENT", # explicit; ignored at query time
)
)
r = await e.embed_query("luxury hotels in Greece")
print(len(r.embedding)) # → 1024 (expected 1536)
asyncio.run(main())
A retriever built on top of this against a VECTOR(1536, FLOAT32) table errors at search time with the ORA-12801 above.
Affected code
locus/rag/embeddings/oci.py:370 (or thereabouts) — embed_details = EmbedTextDetails(... input_type="SEARCH_QUERY", ...) inside embed_query().
Suggested fix
Two non-exclusive options:
-
Honor self.oci_config.input_type when set: only fall through to "SEARCH_QUERY" when the user hasn't supplied one. Lets callers pin both embed_documents and embed_query to the same input_type when they need matching dims.
input_type = self.oci_config.input_type if self.oci_config.input_type else "SEARCH_QUERY"
-
Expose output_dimensions on OCIEmbeddingConfig: Cohere v4 in OCI accepts output_dimensions on the embed request; OCI's EmbedTextDetails exposes it. Letting callers pin a target dim (e.g. 1024 or 1536) makes the request symmetric regardless of input_type.
Either fix unblocks v4-indexed RAG. The first is the smaller change.
Environment
locus-sdk[oci,server] 0.2.0b25
oci 2.176.0
cohere.embed-v4.0 via OCI Generative AI, us-chicago-1
- Oracle 26ai (Autonomous Database, free tier),
VECTOR(1536, FLOAT32) + HNSW cosine index
- Python 3.13
Related
Summary
locus.rag.embeddings.oci.OCIEmbeddings.embed_query()(around line 370 in 0.2.0b25) hardcodesinput_type="SEARCH_QUERY"on the underlyingEmbedTextDetailsrequest, ignoringself.oci_config.input_type.For
cohere.embed-v4.0on OCI Generative AI, the two input_types return different output dimensions:SEARCH_DOCUMENTSEARCH_QUERY(This asymmetry is OCI/Cohere v4 behaviour, not Locus's fault — but it interacts badly with the hardcoded override.)
embed_documents()correctly usesSEARCH_DOCUMENT, so an ingestion path that callsembed_documentspopulates a vector column at 1536 dim. Then a search viaembed_queryreturns a 1024-dim vector.VECTOR_DISTANCE(embedding /*1536*/, :qvec /*1024*/, COSINE)raises:Net result: every RAG query against a v4-indexed table errors out, with no warning at config / startup time.
Reproduction
A retriever built on top of this against a
VECTOR(1536, FLOAT32)table errors at search time with the ORA-12801 above.Affected code
locus/rag/embeddings/oci.py:370(or thereabouts) —embed_details = EmbedTextDetails(... input_type="SEARCH_QUERY", ...)insideembed_query().Suggested fix
Two non-exclusive options:
Honor
self.oci_config.input_typewhen set: only fall through to"SEARCH_QUERY"when the user hasn't supplied one. Lets callers pin bothembed_documentsandembed_queryto the same input_type when they need matching dims.Expose
output_dimensionsonOCIEmbeddingConfig: Cohere v4 in OCI acceptsoutput_dimensionson the embed request; OCI'sEmbedTextDetailsexposes it. Letting callers pin a target dim (e.g. 1024 or 1536) makes the request symmetric regardless of input_type.Either fix unblocks v4-indexed RAG. The first is the smaller change.
Environment
locus-sdk[oci,server]0.2.0b25oci2.176.0cohere.embed-v4.0via OCI Generative AI, us-chicago-1VECTOR(1536, FLOAT32)+ HNSW cosine indexRelated
wallet_password="", breaks auto-login wallets (Pydantic v2 SecretStr is falsy) #289 (just-fixedwallet_passwordtruthy guard) — same RAG path, different bug.