Struct dify_client::client::Client
source · pub struct Client {
pub config: Arc<Config>,
/* private fields */
}Expand description
The Client struct represents a client for interacting with the Dify API.
Fields§
§config: Arc<Config>The configuration for the client.
Implementations§
source§impl Client
impl Client
The Client struct represents a client for interacting with the Dify API.
sourcepub fn new_with_config(c: Config) -> Self
pub fn new_with_config(c: Config) -> Self
sourcepub async fn chat_messages(
&self,
req_data: ChatMessageRequest
) -> Result<ChatMessageResponse>
pub async fn chat_messages( &self, req_data: ChatMessageRequest ) -> Result<ChatMessageResponse>
sourcepub async fn chat_messages_stream<F, T>(
&self,
req_data: ChatMessageRequest,
callback: F
) -> Result<Vec<T>>
pub async fn chat_messages_stream<F, T>( &self, req_data: ChatMessageRequest, callback: F ) -> Result<Vec<T>>
Sends a chat message request to the Dify API and returns the response as a stream.
The callback function is called for each event in the stream.
The callback function should return Some(T) if the event is processed successfully, otherwise None.
The function returns a vector of the processed events.
The stream is stopped when the callback function returns an error or the stream ends.
§Arguments
req_data- The chat message request data.callback- The callback function to process the stream events.
§Returns
A Result containing the processed events or an error.
§Errors
Returns an error if the request cannot be created or the stream fails.
sourcepub async fn files_upload(
&self,
req_data: FilesUploadRequest
) -> Result<FilesUploadResponse>
pub async fn files_upload( &self, req_data: FilesUploadRequest ) -> Result<FilesUploadResponse>
sourcepub async fn chat_messages_stop(
&self,
req_data: ChatMessageStopRequest
) -> Result<ResultResponse>
pub async fn chat_messages_stop( &self, req_data: ChatMessageStopRequest ) -> Result<ResultResponse>
sourcepub async fn messages_suggested(
&self,
req_data: MessagesSuggestedRequest
) -> Result<MessagesSuggestedResponse>
pub async fn messages_suggested( &self, req_data: MessagesSuggestedRequest ) -> Result<MessagesSuggestedResponse>
sourcepub async fn messages_feedbacks(
&self,
req_data: MessagesFeedbacksRequest
) -> Result<ResultResponse>
pub async fn messages_feedbacks( &self, req_data: MessagesFeedbacksRequest ) -> Result<ResultResponse>
sourcepub async fn conversations(
&self,
req_data: ConversationsRequest
) -> Result<ConversationsResponse>
pub async fn conversations( &self, req_data: ConversationsRequest ) -> Result<ConversationsResponse>
sourcepub async fn messages(
&self,
req_data: MessagesRequest
) -> Result<MessagesResponse>
pub async fn messages( &self, req_data: MessagesRequest ) -> Result<MessagesResponse>
sourcepub async fn conversations_renaming(
&self,
req_data: ConversationsRenameRequest
) -> Result<ResultResponse>
pub async fn conversations_renaming( &self, req_data: ConversationsRenameRequest ) -> Result<ResultResponse>
pub async fn conversations_delete( &self, req_data: ConversationsDeleteRequest ) -> Result<()>
sourcepub async fn text_to_audio(&self, req_data: TextToAudioRequest) -> Result<Bytes>
pub async fn text_to_audio(&self, req_data: TextToAudioRequest) -> Result<Bytes>
sourcepub async fn audio_to_text(
&self,
req_data: AudioToTextRequest
) -> Result<AudioToTextResponse>
pub async fn audio_to_text( &self, req_data: AudioToTextRequest ) -> Result<AudioToTextResponse>
sourcepub async fn parameters(
&self,
req_data: ParametersRequest
) -> Result<ParametersResponse>
pub async fn parameters( &self, req_data: ParametersRequest ) -> Result<ParametersResponse>
sourcepub async fn meta(&self, req_data: MetaRequest) -> Result<MetaResponse>
pub async fn meta(&self, req_data: MetaRequest) -> Result<MetaResponse>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
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