-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_rag.py
More file actions
52 lines (48 loc) · 1.46 KB
/
test_rag.py
File metadata and controls
52 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python3
import requests
import psycopg2
import json
# Test Ollama embedding
def test_ollama():
print("Testing Ollama embedding...")
response = requests.post(
"http://localhost:11434/api/embeddings",
json={
"model": "nomic-embed-text",
"prompt": "This is a test"
}
)
if response.status_code == 200:
embedding = response.json()['embedding']
print(f"✓ Ollama working! Embedding dimension: {len(embedding)}")
return True
else:
print(f"✗ Ollama error: {response.status_code} - {response.text}")
return False
# Test PostgreSQL connection
def test_postgres():
print("\nTesting PostgreSQL connection...")
try:
conn = psycopg2.connect(
host="localhost",
port=5432,
database="noteraity_vectors",
user="akashswamy",
password=""
)
cur = conn.cursor()
cur.execute("SELECT COUNT(*) FROM note_chunks")
count = cur.fetchone()[0]
print(f"✓ PostgreSQL working! Current chunks: {count}")
conn.close()
return True
except Exception as e:
print(f"✗ PostgreSQL error: {e}")
return False
if __name__ == "__main__":
ollama_ok = test_ollama()
postgres_ok = test_postgres()
if ollama_ok and postgres_ok:
print("\n✅ All systems operational!")
else:
print("\n❌ Some systems are not working properly")