Commit bf701868 authored by Andrey Filippov's avatar Andrey Filippov

configurable path for MCP/RAG

parent c911c2a7
...@@ -147,6 +147,11 @@ Query parameters: ...@@ -147,6 +147,11 @@ Query parameters:
curl "http://127.0.0.1:48888/mcp/rag/query?text=Explain%20differential%20rectification&topK=5" curl "http://127.0.0.1:48888/mcp/rag/query?text=Explain%20differential%20rectification&topK=5"
``` ```
RAG root path (optional, for non-standard checkouts):
```
-Delphel.rag.root=/home/elphel/wksp2/imagej-elphel
```
Example (config directory): Example (config directory):
``` ```
-Delphel.mcp.allowed.configdir=/media/elphel/btrfs-data/lwir16-proc/NC/config -Delphel.mcp.allowed.configdir=/media/elphel/btrfs-data/lwir16-proc/NC/config
......
...@@ -552,8 +552,12 @@ public class McpServer { ...@@ -552,8 +552,12 @@ public class McpServer {
if (topK < 1) { if (topK < 1) {
topK = 1; topK = 1;
} }
String venvPython = "/home/elphel/git/imagej-elphel/attic/CODEX/rag_index/.venv/bin/python"; String ragRoot = System.getProperty("elphel.rag.root");
String script = "/home/elphel/git/imagej-elphel/scripts/rag_query.py"; if (ragRoot == null || ragRoot.trim().isEmpty()) {
ragRoot = "/home/elphel/git/imagej-elphel";
}
String venvPython = ragRoot + "/attic/CODEX/rag_index/.venv/bin/python";
String script = ragRoot + "/scripts/rag_query.py";
List<String> cmd = new ArrayList<String>(); List<String> cmd = new ArrayList<String>();
cmd.add(venvPython); cmd.add(venvPython);
cmd.add(script); cmd.add(script);
...@@ -567,7 +571,8 @@ public class McpServer { ...@@ -567,7 +571,8 @@ public class McpServer {
try { try {
p = pb.start(); p = pb.start();
} catch (IOException e) { } catch (IOException e) {
sendJson(exchange, 500, "{\"ok\":false,\"error\":\"Failed to start rag_query\"}"); String detail = jsonEscape("rag_root=" + ragRoot + " venv=" + venvPython + " script=" + script + " err=" + e.getMessage());
sendJson(exchange, 500, "{\"ok\":false,\"error\":\"Failed to start rag_query\",\"detail\":\"" + detail + "\"}");
return; return;
} }
byte[] out; byte[] out;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment