9 releases

0.2.1 Sep 11, 2023
0.2.0 Sep 11, 2023
0.1.6 Jul 13, 2023
0.1.3 Jun 30, 2023

#6 in #integrating

Download history 80/week @ 2024-06-17 93/week @ 2024-06-24 34/week @ 2024-07-01 33/week @ 2024-07-08 79/week @ 2024-07-15 73/week @ 2024-07-22 106/week @ 2024-07-29 70/week @ 2024-08-05 87/week @ 2024-08-12 66/week @ 2024-08-19 54/week @ 2024-08-26 96/week @ 2024-09-02 92/week @ 2024-09-09 84/week @ 2024-09-16 112/week @ 2024-09-23 93/week @ 2024-09-30

393 downloads per month

MIT/Apache

14KB
241 lines

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

Visit Claude

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.

Dependencies

~1–2MB
~43K SLoC