Class Introduction

Function

Interconnects with server configuration parameters.

Prototype

from mx_rag.utils import ClientParam
ClientParam(use_http, ca_file, crl_file, timeout, response_limit_size)

Parameters

Parameter

Data Type

Required/Optional

Description

use_http

Bool

Optional

Whether the client can use the HTTP protocol. The default value is False, indicating that the HTTPS protocol is used.

NOTE:

HTTPS is recommended, as it is more secure than HTTP.

ca_file

String

Optional

Root certificate for connecting to the server. The default value is "". The path length cannot exceed 1024 characters. The path cannot be a soft link and cannot contain two consecutive dots (..). The file size cannot exceed 1 MB.

crl_file

String

Optional

CRL for connecting to the server. The default value is "". The path length cannot exceed 1024 characters. The path cannot be a soft link and cannot contain two consecutive dots (..). The file size cannot exceed 1 MB.

timeout

Integer

Optional

Response timeout interval for connecting to the server, in seconds. The value range is (0, 600]. The default value is 60.

response_limit_size

Integer

Optional

Maximum size of a response received by the client from the server. The value range is (0, 10 MB]. The default value is 1 MB.

When a client is created, use_http is checked. If HTTPS is enabled, ca_file is required. If only ca_file is passed, the TLS/SSL context for one-way authentication is created. If HTTPS is disabled, the default TLS/SSL context is configured on the client.

Example

from mx_rag.llm import Text2TextLLM, LLMParameterConfig
from mx_rag.utils import ClientParam
llm = Text2TextLLM(base_url="https://{ip}:{port}/v1/chat/completions",
                   model_name="qianwen-7b",
                   llm_config=LLMParameterConfig(max_tokens=512),
                   client_param=ClientParam(ca_file="/path/to/ca.crt")
                   )
res = llm.chat("Please introduce Beijing.")
print(res)
for res in llm.chat_streamly("Please introduce Beijing."):
    print(res)