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: ChatMessagesRequest
) -> Result<ChatMessagesResponse>
pub async fn chat_messages( &self, req_data: ChatMessagesRequest ) -> Result<ChatMessagesResponse>
sourcepub async fn chat_messages_stream<F, T>(
&self,
req_data: ChatMessagesRequest,
callback: F
) -> Result<Vec<T>>
pub async fn chat_messages_stream<F, T>( &self, req_data: ChatMessagesRequest, 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: StreamTaskStopRequest
) -> Result<ResultResponse>
pub async fn chat_messages_stop( &self, req_data: StreamTaskStopRequest ) -> 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>
sourcepub async fn conversations_delete(
&self,
req_data: ConversationsDeleteRequest
) -> Result<()>
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>
sourcepub async fn workflows_run(
&self,
req_data: WorkflowsRunRequest
) -> Result<WorkflowsRunResponse>
pub async fn workflows_run( &self, req_data: WorkflowsRunRequest ) -> Result<WorkflowsRunResponse>
sourcepub async fn workflows_run_stream<F, T>(
&self,
req_data: WorkflowsRunRequest,
callback: F
) -> Result<Vec<T>>
pub async fn workflows_run_stream<F, T>( &self, req_data: WorkflowsRunRequest, callback: F ) -> Result<Vec<T>>
Sends a request to run workflows from 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 workflows run 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 workflows_stop(
&self,
req_data: StreamTaskStopRequest
) -> Result<ResultResponse>
pub async fn workflows_stop( &self, req_data: StreamTaskStopRequest ) -> Result<ResultResponse>
sourcepub async fn completion_messages(
&self,
req_data: CompletionMessagesRequest
) -> Result<CompletionMessagesResponse>
pub async fn completion_messages( &self, req_data: CompletionMessagesRequest ) -> Result<CompletionMessagesResponse>
sourcepub async fn completion_messages_stream<F, T>(
&self,
req_data: CompletionMessagesRequest,
callback: F
) -> Result<Vec<T>>
pub async fn completion_messages_stream<F, T>( &self, req_data: CompletionMessagesRequest, callback: F ) -> Result<Vec<T>>
Sends a request to create completion messages from 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 completion messages 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.