Struct openai_flows::OpenAIFlows
source · pub struct OpenAIFlows { /* private fields */ }
Implementations§
source§impl OpenAIFlows
impl OpenAIFlows
sourcepub async fn chat_completion(
&self,
conversation_id: &str,
sentence: &str,
options: &ChatOptions<'_>
) -> Result<ChatResponse, String>
pub async fn chat_completion( &self, conversation_id: &str, sentence: &str, options: &ChatOptions<'_> ) -> Result<ChatResponse, String>
Create chat completion with the provided sentence. It use OpenAI’s GPT-3.5 model to make a conversation.
conversation_id
is the identity of the conversation.
The history will be fetched and attached to the sentence
as a whole prompt for ChatGPT.
sentence
is a String reprensent the sentence of the conversation.
If you have not connected your OpenAI account with Flows.network platform, you will receive an error in the flow’s building log or running log.
source§impl OpenAIFlows
impl OpenAIFlows
sourcepub async fn create_completion(
&self,
params: CompletionRequest
) -> Result<Vec<String>, String>
pub async fn create_completion( &self, params: CompletionRequest ) -> Result<Vec<String>, String>
Create completion for the provided prompt and parameters.
params
is a CompletionRequest object.
If you have not connected your OpenAI account with Flows.network platform, you will receive an error in the flow’s building log or running log.
source§impl OpenAIFlows
impl OpenAIFlows
sourcepub async fn create_embeddings(
&self,
input: EmbeddingsInput
) -> Result<Vec<Vec<f64>>, String>
pub async fn create_embeddings( &self, input: EmbeddingsInput ) -> Result<Vec<Vec<f64>>, String>
Create embeddings from the provided input.
params
is a [EmbeddingsRequest] object.
If you have not connected your OpenAI account with Flows.network platform, you will receive an error in the flow’s building log or running log.
source§impl OpenAIFlows
impl OpenAIFlows
sourcepub async fn crate_image(
&self,
params: ImageRequest
) -> Result<Vec<String>, String>
pub async fn crate_image( &self, params: ImageRequest ) -> Result<Vec<String>, String>
Create image for the provided prompt and parameters.
params
is a ImageRequest object.
If you have not connected your OpenAI account with Flows.network platform, you will receive an error in the flow’s building log or running log.
source§impl OpenAIFlows
impl OpenAIFlows
The main struct for setting the basic configuration for OpenAI interface.
account
is an FlowsAccount used for picking your tied OpenAI API key.
Use retry_times to set the number of retries when requesting OpenAI’s api encounters a problem. Default is 2 and max number is 10.