-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_query.py
49 lines (43 loc) · 1.27 KB
/
client_query.py
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
"""
Example of querying nilDB with NilAI using nilRAG.
"""
import os
import sys
import json
from nilrag.nildb_requests import NilDB, Node
JSON_FILE = "examples/query_nildb_config.json"
# Load NilDB from JSON file if it exists
if os.path.exists(JSON_FILE):
print("Loading NilDB configuration from file...")
with open(JSON_FILE, "r", encoding="utf-8") as f:
data = json.load(f)
nodes = []
for node_data in data["nodes"]:
nodes.append(
Node(
url=node_data["url"],
node_id=None,
org=None,
bearer_token=node_data.get("bearer_token"),
schema_id=node_data.get("schema_id"),
diff_query_id=node_data.get("diff_query_id"),
)
)
nilDB = NilDB(nodes)
else:
print("Error: NilDB configuration file not found.")
sys.exit(1)
print("NilDB instance:", nilDB)
print()
print('Query nilAI with nilRAG...')
response = nilDB.nilai_chat_completion(
nilai_url="http://127.0.0.1:8080/",
token="1770c101-dd83-4fbc-b996-ef8121889172",
messages=[
{"role": "user", "content": "Tell me about Asia."}
],
temperature=0.2,
max_tokens=2048,
stream=False,
)
print(response)