File size: 1,878 Bytes
932db78
 
 
 
 
 
 
 
 
0fd4a4d
932db78
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0fd4a4d
 
 
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
import os
from pymilvus import (
    utility,
    FieldSchema,
    CollectionSchema,
    DataType,
    Collection,
)

from db_connect import connect, disconnect

connect()

#region creating collections
### Create collections ###
fields = [
    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    FieldSchema(name="text", dtype=DataType.VARCHAR, max_length=65535),
    FieldSchema(name="embeddings", dtype=DataType.FLOAT_VECTOR, dim=384)
]
schema = CollectionSchema(fields, "Texts to generate audio for. "
                                  "This collection cache the texts needed to generate audio. "
                                  "We can then do offline generation for the audio file.")
utility.drop_collection("Response")
response_collection = Collection("Response", schema)
index_params = {
  "metric_type": "COSINE",
  "index_type": "IVF_FLAT",
  "params": {"nlist": 1024}
}
response_collection.create_index(field_name='embeddings', index_params=index_params)
utility.index_building_progress("Response")


fields = [
    FieldSchema(name="id", dtype=DataType.INT64, is_primary=True, auto_id=True),
    FieldSchema(name="text", dtype=DataType.VARCHAR, max_length=65535),
    FieldSchema(name="filename", dtype=DataType.VARCHAR, max_length=65535),
    FieldSchema(name="embeddings", dtype=DataType.FLOAT_VECTOR, dim=384)
]
audio_schema = CollectionSchema(fields, "The text that corresponds to the audio file.")
utility.drop_collection("AudioResponse")
audio_response_collection = Collection("AudioResponse", audio_schema)
audio_response_collection = Collection("AudioResponse")
index_params = {
  "metric_type": "COSINE",
  "index_type": "IVF_FLAT",
  "params": {"nlist": 1024}
}
audio_response_collection.create_index(field_name='embeddings', index_params=index_params)
utility.index_building_progress("AudioResponse")
#endregion

disconnect()