Crate openai_flows
source ·Expand description
OpenAI integration for Flows.network
Quick Start
To get started, let’s write a very tiny flow function.
use openai_flows::{CompletionRequest, create_completion};
use slack_flows::{listen_to_channel, send_message_to_channel};
#[no_mangle]
pub fn run() {
listen_to_channel("myworkspace", "mychannel", |sm| {
let cr = CompletionRequest {
prompt: sm.text,
..Default::default()
};
let r = create_completion("myaccount", cr);
r.iter().for_each(|c| {
send_message_to_channel("myworkspace", "mychannel", c.to_string());
});
});
}
When the Slack message is received, create completion using create_completion then send the response to Slack.
Structs
- struct for setting the chat options.
- Response struct for the chat completion.
- Request struct for the completion.
- Request struct for the image creation.
Enums
- Models for Chat
Functions
- Create chat completion with the provided sentence. It use OpenAI’s GPT-3.5 model to make a conversation. It will keep the conversation history for 10 minutes for you. That means a new conversation will be created if you haven’t call this method for 10 minutes.
- Create completion for the provided prompt and parameters.
- Create image for the provided prompt and parameters.