pub struct ChatClient {
pub base_url: String,
pub auth_token: Option<String>,
pub http_client: Client,
}Expand description
The object to hold information about the model server and reqwest HTTP client.
Fields§
§base_url: String§auth_token: Option<String>§http_client: ClientImplementations§
Source§impl ChatClient
impl ChatClient
Sourcepub fn init(base_url: String, auth_token: Option<String>) -> Self
pub fn init(base_url: String, auth_token: Option<String>) -> Self
Create a new ChatClient instance, which hosts the basic information and reqwest client for making the requests
Args:
base_urlBase url of the API server. This URL should NOT end with ‘/’.auth_tokenBearer authentication token. It is often called “API Key”.
Sourcepub fn create_chat_completion_request(
&self,
model: &str,
messages: &Vec<ChatMessage>,
is_stream: bool,
params: &HashMap<String, Value>,
) -> RequestBuilder
pub fn create_chat_completion_request( &self, model: &str, messages: &Vec<ChatMessage>, is_stream: bool, params: &HashMap<String, Value>, ) -> RequestBuilder
Create a chat completion request.
Args:
modelName of the model to be called.messagesA Vec of ChatMessage as the context.is_streamWhether the request is stream-based.paramsOther parameters to be sent.
Sourcepub async fn chat_completion_stream(
&self,
model: &str,
messages: &Vec<ChatMessage>,
params: &HashMap<String, Value>,
) -> Result<impl Stream<Item = Result<ChatResponseChunkDelta>>>
pub async fn chat_completion_stream( &self, model: &str, messages: &Vec<ChatMessage>, params: &HashMap<String, Value>, ) -> Result<impl Stream<Item = Result<ChatResponseChunkDelta>>>
Request chat completion in the async stream approach.
Args:
modelName of the model to be called.messagesA Vec of ChatMessage as the context.paramsOther parameters to be sent.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ChatClient
impl !RefUnwindSafe for ChatClient
impl Send for ChatClient
impl Sync for ChatClient
impl Unpin for ChatClient
impl !UnwindSafe for ChatClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more