Documentation ¶
Index ¶
- Constants
- func AesGcmDecryptBase64String(key, nonce []byte, ciphertext string) (string, error)
- func AesGcmDecryptBytes(key, nonce, cipherBytes []byte) ([]byte, error)
- func AesGcmEncryptBase64String(key, nonce []byte, plaintext string) (string, error)
- func AesGcmEncryptBytes(key, nonce, plain []byte) ([]byte, error)
- func ECDHMarshalBinary(pub *ecdsa.PublicKey) []byte
- func GenerateKey(curve elliptic.Curve) (*ecdsa.PrivateKey, *ecdsa.PublicKey, error)
- func GetRetrySetting(serviceRetrySettings, apiRetrySettings *base.RetrySettings) *base.RetrySettings
- func GetTimeout(serviceTimeout, apiTimeout time.Duration) time.Duration
- func MakeRequest(apiInfo *base.ApiInfo, endpointId string, serviceInfo *base.ServiceInfo, ...) (*http.Request, error)
- func MarshalBinary(pub *ecdsa.PublicKey) []byte
- func MergeHeader(header1, header2 http.Header) (header http.Header)
- func MergeQuery(query1, query2 url.Values) (query url.Values)
- func ReadCertFromBytes(pemBytes []byte) (*x509.Certificate, error)
- func ReadCertFromString(pemString string) (*x509.Certificate, error)
- func ReadEcdsaPrivKeyFromBytes(pemBytes []byte) (*ecdsa.PrivateKey, error)
- func ReadEcdsaPrivKeyFromString(key string) (*ecdsa.PrivateKey, error)
- func UnmarshalBinary(curve elliptic.Curve, data []byte) (*big.Int, *big.Int)
- type KeyAgreementClient
- type KeyAgreementVendor
- type MaaS
- func (cli *MaaS) Chat(req *api.ChatReq) (*api.ChatResp, int, error)
- func (cli *MaaS) ChatImpl(ctx context.Context, body []byte) (*api.ChatResp, int, error)
- func (cli *MaaS) ChatWithCtx(ctx context.Context, req *api.ChatReq) (*api.ChatResp, int, error)
- func (cli *MaaS) Classification(req *api.ClassificationReq) (*api.ClassificationResp, int, error)
- func (cli *MaaS) ClassificationWithCtx(ctx context.Context, req *api.ClassificationReq) (*api.ClassificationResp, int, error)
- func (cli *MaaS) Embeddings(req *api.EmbeddingsReq) (*api.EmbeddingsResp, int, error)
- func (cli *MaaS) EmbeddingsWithCtx(ctx context.Context, req *api.EmbeddingsReq) (*api.EmbeddingsResp, int, error)
- func (cli *MaaS) SecretChat(req *api.ChatReq) (*api.ChatResp, int, error)
- func (cli *MaaS) SecretChatWithCtx(ctx context.Context, req *api.ChatReq) (*api.ChatResp, int, error)
- func (cli *MaaS) SecretStreamChat(req *api.ChatReq) (ch <-chan *api.ChatResp, err error)
- func (cli *MaaS) SecretStreamChatWithCtx(ctx context.Context, req *api.ChatReq) (ch <-chan *api.ChatResp, err error)
- func (cli *MaaS) StreamChat(req *api.ChatReq) (ch <-chan *api.ChatResp, err error)
- func (cli *MaaS) StreamChatImpl(ctx context.Context, body []byte) (<-chan *api.ChatResp, error)
- func (cli *MaaS) StreamChatWithCtx(ctx context.Context, req *api.ChatReq) (ch <-chan *api.ChatResp, err error)
- func (cli *MaaS) Tokenization(req *api.TokenizeReq) (*api.TokenizeResp, int, error)
- func (cli *MaaS) TokenizationWithCtx(ctx context.Context, req *api.TokenizeReq) (*api.TokenizeResp, int, error)
- type ResponseContent
Constants ¶
const ( ServiceName = "ml_maas" APICert = "cert" APIChat = "chat" APIStreamChat = "stream_chat" APITokenization = "tokenization" APIClassification = "classification" APIEmbeddings = "embeddings" APIImagesQuickGen = "images.quick_gen" APIImagesFlexGen = "images.flex_gen" APIAudioSpeech = "audio.speech" TOP = "top" ServiceTimeout = time.Minute MaxBufferSize = 4194304 RespBufferSize = 32 Terminator = "[DONE]" ChatRoleOfUser = "user" ChatRoleOfAssistant = "assistant" ChatRoleOfSystem = "system" ChatRoleOfFunction = "function" )
Variables ¶
This section is empty.
Functions ¶
func AesGcmDecryptBase64String ¶
AesGcmDecryptBase64String decrypt message(base64.std.string) using AES-GCM
func AesGcmDecryptBytes ¶
AesGcmDecryptBytes Decrypt message using AES-GCM
func AesGcmEncryptBase64String ¶
AesGcmEncryptBase64String Encrypt message from base64 string to string using AES-GCM
func AesGcmEncryptBytes ¶
AesGcmEncryptBytes encrypt message using AES-GCM
func ECDHMarshalBinary ¶
func GenerateKey ¶
GenerateKey is the constructor for Private-Public key pair
func GetRetrySetting ¶
func GetRetrySetting(serviceRetrySettings, apiRetrySettings *base.RetrySettings) *base.RetrySettings
func MakeRequest ¶
func MarshalBinary ¶
func ReadCertFromBytes ¶
func ReadCertFromBytes(pemBytes []byte) (*x509.Certificate, error)
func ReadCertFromString ¶
func ReadCertFromString(pemString string) (*x509.Certificate, error)
func ReadEcdsaPrivKeyFromBytes ¶
func ReadEcdsaPrivKeyFromBytes(pemBytes []byte) (*ecdsa.PrivateKey, error)
func ReadEcdsaPrivKeyFromString ¶
func ReadEcdsaPrivKeyFromString(key string) (*ecdsa.PrivateKey, error)
Types ¶
type KeyAgreementClient ¶
type KeyAgreementClient struct {
// contains filtered or unexported fields
}
func NewP256KeyAgreementClient ¶
func NewP256KeyAgreementClient(pemString string) (*KeyAgreementClient, error)
NewP256KeyAgreementClient Load cert and extract public key
func (*KeyAgreementClient) CheckChain ¶
func (k *KeyAgreementClient) CheckChain(pemChainString string) error
CheckChain validate cert and cert chain
func (*KeyAgreementClient) GenerateECIESKeyPair ¶
func (k *KeyAgreementClient) GenerateECIESKeyPair() ([]byte, []byte, string, error)
GenerateECIESKeyPair generate ECIES key pair and return the tuple (key, nonce, session token, error)
type KeyAgreementVendor ¶
type KeyAgreementVendor struct {
// contains filtered or unexported fields
}
func NewP256KeyAgreementVendor ¶
func NewP256KeyAgreementVendor(key string) (*KeyAgreementVendor, error)
NewP256KeyAgreementVendor Load private key
func (*KeyAgreementVendor) DecryptString ¶
func (k *KeyAgreementVendor) DecryptString(sessionToken string, ciphertext string) ([]byte, []byte, string, error)
DecryptString decide ciphered text with ECIES DH protocol and return the tuple of (key, nonce, decrypted text)
func (*KeyAgreementVendor) ExtractECIESKeyPair ¶
func (k *KeyAgreementVendor) ExtractECIESKeyPair(sessionToken string) ([]byte, []byte, error)
ExtractECIESKeyPair extract ECIES key pair from session token and return the tuple of (key, nonce)
type MaaS ¶
MaaS ... use base client
func (*MaaS) ChatWithCtx ¶
POST method ChatWithCtx ...
func (*MaaS) Classification ¶
func (cli *MaaS) Classification(req *api.ClassificationReq) (*api.ClassificationResp, int, error)
POST method Classification
func (*MaaS) ClassificationWithCtx ¶
func (cli *MaaS) ClassificationWithCtx(ctx context.Context, req *api.ClassificationReq) (*api.ClassificationResp, int, error)
func (*MaaS) Embeddings ¶
func (cli *MaaS) Embeddings(req *api.EmbeddingsReq) (*api.EmbeddingsResp, int, error)
POST method Embeddings
func (*MaaS) EmbeddingsWithCtx ¶
func (cli *MaaS) EmbeddingsWithCtx(ctx context.Context, req *api.EmbeddingsReq) (*api.EmbeddingsResp, int, error)
func (*MaaS) SecretChat ¶
POST method SecretChat is like `Chat`, except its messages are encrypted to ensure that messages are not intercepted by receivers other than the model.
func (*MaaS) SecretChatWithCtx ¶
func (cli *MaaS) SecretChatWithCtx(ctx context.Context, req *api.ChatReq) (*api.ChatResp, int, error)
POST method SecretChatWithCtx is like `ChatWithCtx`, except its messages are encrypted to ensure that messages are not intercepted by receivers other than the model.
func (*MaaS) SecretStreamChat ¶
POST method SecretStreamChat is like `StreamChat`, except its messages are encrypted to ensure that messages are not intercepted by receivers other than the model.
func (*MaaS) SecretStreamChatWithCtx ¶
func (cli *MaaS) SecretStreamChatWithCtx(ctx context.Context, req *api.ChatReq) (ch <-chan *api.ChatResp, err error)
POST method SecretStreamChatWithCtx is like `StreamChatWithCtx`, except its messages are encrypted to ensure that messages are not intercepted by receivers other than the model.
func (*MaaS) StreamChat ¶
POST method StreamChat make stream chat request
- if any error returned, a channel=`nil` is returned;
- if no error returned, the channel are closed after all responses processed.
func (*MaaS) StreamChatImpl ¶
func (*MaaS) StreamChatWithCtx ¶
func (cli *MaaS) StreamChatWithCtx(ctx context.Context, req *api.ChatReq) (ch <-chan *api.ChatResp, err error)
POST method StreamChat make stream chat request
- if any error returned, a channel=`nil` is returned;
- if no error returned, the channel are closed after all responses processed.
func (*MaaS) Tokenization ¶
func (cli *MaaS) Tokenization(req *api.TokenizeReq) (*api.TokenizeResp, int, error)
POST method Tokenization
func (*MaaS) TokenizationWithCtx ¶
func (cli *MaaS) TokenizationWithCtx(ctx context.Context, req *api.TokenizeReq) (*api.TokenizeResp, int, error)
type ResponseContent ¶
type ResponseContent interface { io.ReadCloser GetRequestId() string }
func NewBinaryResponseContent ¶
func NewBinaryResponseContent(i io.ReadCloser, requestId string, cancel context.CancelFunc) ResponseContent