Crates.io | claude-flows |
lib.rs | claude-flows |
version | 0.2.1 |
source | src |
created_at | 2023-06-27 10:11:58.154983 |
updated_at | 2023-09-11 10:55:10.395426 |
description | Claude integration for flows.network |
homepage | |
repository | |
max_upload_size | |
id | 901196 |
size | 13,999 |
This is a library for integrating Claude in your flow function for flows.network.
use flowsnet_platform_sdk::logger;
use lambda_flows::{request_received, send_response};
use claude_flows::{
chat::ChatOptions,
ClaudeFlows,
};
use serde_json::Value;
use std::collections::HashMap;
#[no_mangle]
#[tokio::main(flavor = "current_thread")]
pub async fn run() {
logger::init();
request_received(handler).await;
}
async fn handler(_qry: HashMap<String, Value>, body: Vec<u8>) {
let co = ChatOptions::default();
let of = ClaudeFlows::new();
let r = match of
.chat_completion(
"any_conversation_id",
String::from_utf8_lossy(&body).into_owned().as_str(),
&co,
)
.await
{
Ok(c) => c,
Err(e) => e,
};
send_response(
200,
vec![(
String::from("content-type"),
String::from("text/plain; charset=UTF-8"),
)],
r.as_bytes().to_vec(),
);
}
This example lets you have a conversation with Claude using chat_completion
by Lambda request.
The whole document is here.