-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.py
77 lines (66 loc) · 1.35 KB
/
schema.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# :create table {k: String => v: <F32; 128>}
from pycozo.client import Client
import numpy as np
client = Client('sqlite', 'explanations.db')
script = """
:create documentation_explanations {
code: String,
=>
code_embedding: <F32; 384>,
language: String,
documentation: String,
documentation_url: String,
llm_explanation: String,
}
"""
try:
res = client.run(script)
except Exception as e:
print(f"An error occurred: {e}")
script = """
::hnsw create documentation_explanations:index {
dim: 384,
m: 50,
dtype: F32,
fields: [code_embedding],
distance: L2,
ef_construction: 20,
extend_candidates: false,
keep_pruned_connections: false,
}
"""
try:
res = client.run(script)
except Exception as e:
print(f"An error occurred: {e}")
script = """
:create gh_explanations {
code: String,
=>
code_embedding: <F32; 384>,
commit_message: String,
llm_explanation: String,
}
"""
try:
res = client.run(script)
except Exception as e:
print(f"An error occurred: {e}")
script = """
::hnsw create gh_explanations:index {
dim: 384,
m: 50,
dtype: F32,
fields: [code_embedding],
distance: L2,
ef_construction: 20,
extend_candidates: true,
keep_pruned_connections: false,
}
"""
try:
res = client.run(script)
# print(res)
except Exception as e:
print(f"An error occurred: {e}")
client.close()