This is a library for integrating OpenAI in your flow function for flows.network.

Usage example

```rust use openaiflows::{CompletionRequest, createcompletion}; use slackflows::{listentochannel, sendmessagetochannel};

[no_mangle]

pub fn run() { listentochannel("myworkspace", "mychannel", |sm| { let cr = CompletionRequest { prompt: sm.text, ..Default::default() }; let r = createcompletion("myaccount", cr); r.iter().foreach(|c| { sendmessagetochannel("myworkspace", "mychannel", c.tostring()); }); }); } ```

When a new message is received from mychannel, we will create completions using create_completion then send the result back to Slack.

Visit ChatGPT

```rust use openaiflows::{chatcompletion, ChatOptions, ChatModel}; use slackflows::{listentochannel, sendmessagetochannel};

[no_mangle]

pub fn run() { listentochannel("myworkspace", "mychannel", |sm| { let co = ChatOptions { model: ChatModel::GPT35Turbo, restart: sm.text.eqignoreasciicase("/restart"), restartedsentence: Some("let's change the subject"), retrytimes: 2, }; if let Some(r) = chatcompletion("myaccount", "anyconversationid", &sm.text, &co) { sendmessageto_channel("myworkspace", "mychannel", r.choice); } }); } ```

This example lets you have a conversation with ChatGPT using chat_completion in Slack. When you want to restart a new topic, just type /restart.

The whole document is here.