MCPcopy Create free account
hub / github.com/coderabbit214/document-ai / CreateCollection

Function CreateCollection

pkg/qdrant/collection.go:38–62  ·  view source on GitHub ↗

CreateCollection creates a collection in qdrant

(name string, createCollectionRequest CreateCollectionRequest)

Source from the content-addressed store, hash-verified

36
37// CreateCollection creates a collection in qdrant
38func CreateCollection(name string, createCollectionRequest CreateCollectionRequest) (err error) {
39 response := &CommonResponse{}
40 var reqBytes []byte
41 reqBytes, err = json.Marshal(createCollectionRequest)
42 if err != nil {
43 common.Logger.Error(err.Error())
44 return
45 }
46
47 body, err := Send(http.MethodPut, collectionApi+"/"+name, reqBytes)
48 if err != nil {
49 common.Logger.Error(err.Error())
50 return
51 }
52
53 err = json.Unmarshal(body, &response)
54 if err != nil {
55 return
56 }
57 if response.Result == nil {
58 return errors.New(response.Status.(map[string]interface{})["error"].(string))
59 }
60 return
61
62}
63
64func GetCollection(name string) (err error) {
65 response := &CommonResponse{}

Callers 2

initFunction · 0.85
TestCreateCollectionFunction · 0.85

Calls 1

SendFunction · 0.70

Tested by 1

TestCreateCollectionFunction · 0.68