PaLM API

crates.io Documentation MIT/Apache-2 licensed

Get started using the PaLM API in Rust.

Usage

Get an API key from MakerSuite, then configure it here. ```rust,norun use palmapi::palm::create_client;

client = createclient(PALMAPIKEY.tostring()); ```

Use PalmClient's generate_text() method to have the model complete some initial text. ```rust,norun use palmapi::palm::newtextbody;

let mut textbody = newtextbody(); textbody.settextprompt("The opposite of hot is".tostring()); let response = client .generatetext("text-bison-001".tostring(), textbody) .expect("An error has occured."); println!("{}", response.candidates.unwrap()[0].output); ```

Use PalmClient's chat() method to have a discussion with a model. ```rust,norun use palmapi::palm::newchatbody;

let mut chatbody = newchatbody(); chatbody.appendmessage("Hello.".tostring()); let response = client .chat("chat-bison-001".tostring(), chatbody) .expect("An error has occured."); println!("{}", response.candidates.unwrap()[0].content); ```