15 lines
935 B
Bash
Executable File
15 lines
935 B
Bash
Executable File
#!/bin/bash
|
|
# Store episodic memory in Qdrant
|
|
TEXT="$*"
|
|
if [ -z "$TEXT" ]; then echo '{"error":"no text"}'; exit 1; fi
|
|
# Embed via Ollama nomic
|
|
EMBED=$(curl -sS --max-time 10 -X POST http://localhost:11434/api/embeddings \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"model\":\"nomic-embed-text\",\"prompt\":\"$TEXT\"}" 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); print(json.dumps(d.get('embedding',[])))" 2>/dev/null)
|
|
if [ -z "$EMBED" ] || [ "$EMBED" = "[]" ]; then echo '{"error":"embed failed"}'; exit 1; fi
|
|
ID=$(date +%s)
|
|
PAYLOAD="{\"points\":[{\"id\":$ID,\"vector\":$EMBED,\"payload\":{\"text\":\"$TEXT\",\"ts\":\"$(date -Iseconds)\",\"source\":\"memory_store\"}}]}"
|
|
RESP=$(curl -sS --max-time 10 -X PUT "http://localhost:6333/collections/wevia_memory_768/points" \
|
|
-H "Content-Type: application/json" -d "$PAYLOAD" 2>&1)
|
|
echo "{\"stored\":true,\"id\":$ID,\"qdrant\":\"$(echo $RESP | head -c 100)\"}"
|