a month ago
Hello, everyone,
I referred these two links cap-ai-vector-engine-sample ,cap-llm-plugin-samples to develop a CAP RAG application.
When I insert the embedding data into the db, I got an error message "argument type mismatch: Result is not a single value".
After my research, I found that if the dependency @SAP/cds-hana is added, data can be inserted into the database successfully, However, my App use Fiori elements and enbaled draft function, if the @SAP/cds-hana dependency is used, my Fiori app will encounter an error: SqlError: invalid column name: DRAFTADMINISTRATIVEDATA.INPROCESSBYUSER. When this dependency is removed, the Fiori app will not report an error, but I won't be able to insert data into the db. It seems that this is a dilemma, So, is there a conflict between @SAP/cds-hana and the draft-enabled function? And is there any way to insert data into the db normally without using this dependency?
Any advice or suggestions would be appreciated.
schema.cds
entity DocumentChunk : cuid, managed {
file : Association to Files;
text_chunk : LargeString;
metadata_column : LargeString;
embedding : Vector(1536);
}
service.js ( insert into db )
const embeddingResult = await capllmplugin.getEmbeddingWithConfig(
embeddingModelConfig,
chunk.pageContent
);
embedding = embeddingResult?.data[0]?.embedding;
const entry = {
file_ID: uuid,
text_chunk: chunk.pageContent,
metadata_column: fileName,
embedding: array2VectorBuffer(embedding),
};
textChunkEntries.push(entry);
// Insert the text chunk with embeddings into db
const insertStatus = await INSERT.into(DocumentChunk).entries(
textChunkEntries
);
package.json
"dependencies": {
"@sap-cloud-sdk/http-client": "3.25.0",
"@sap-cloud-sdk/resilience": "3.25.0",
"@sap/cds": "^8",
"@cap-js/hana": "^1",
"@sap/xssec": "^4",
"cap-llm-plugin": "^1.4.4",
"express": "^4",
"langchain": "^0.1.19",
}
Request clarification before answering.
The following change would get you going with cap-js/hana
> embedding: array2VectorBuffer(embedding),
----
< embedding: JSON.stringify(embedding),
You could ask for supporting binary representation at https://github.com/cap-js/cds-dbs/issues
PS: I see that native queries support binary representation. You could try that too and let us know if that works better than text representation. 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dinu,
wow, it's really an amazing change.
It does work after making change as you suggested, Thank you so much.
BTW, due to this issue previously, I found another workaround by using the trigger of Hana Cloud. So I will try what you said later.
Thank you again.
User | Count |
---|---|
61 | |
7 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.