github.com/weaviate/weaviate@v1.24.6/modules/text2vec-gpt4all/clients/meta.go (about)

     1  //                           _       _
     2  // __      _____  __ ___   ___  __ _| |_ ___
     3  // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \
     4  //  \ V  V /  __/ (_| |\ V /| | (_| | ||  __/
     5  //   \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___|
     6  //
     7  //  Copyright © 2016 - 2024 Weaviate B.V. All rights reserved.
     8  //
     9  //  CONTACT: hello@weaviate.io
    10  //
    11  
    12  package clients
    13  
    14  import (
    15  	"context"
    16  	"encoding/json"
    17  	"io"
    18  	"net/http"
    19  
    20  	"github.com/pkg/errors"
    21  )
    22  
    23  func (c *client) MetaInfo() (map[string]interface{}, error) {
    24  	req, err := http.NewRequestWithContext(context.Background(), "GET", c.url("/meta"), nil)
    25  	if err != nil {
    26  		return nil, errors.Wrap(err, "create GET meta request")
    27  	}
    28  
    29  	res, err := c.httpClient.Do(req)
    30  	if err != nil {
    31  		return nil, errors.Wrap(err, "send GET meta request")
    32  	}
    33  	defer res.Body.Close()
    34  
    35  	bodyBytes, err := io.ReadAll(res.Body)
    36  	if err != nil {
    37  		return nil, errors.Wrap(err, "read meta response body")
    38  	}
    39  
    40  	var resBody map[string]interface{}
    41  	if err := json.Unmarshal(bodyBytes, &resBody); err != nil {
    42  		return nil, errors.Wrap(err, "unmarshal meta response body")
    43  	}
    44  	return resBody, nil
    45  }