Get started using the PaLM API in Rust.
Get an API key from MakerSuite, then configure it here. ```rust,norun use palmapi::palm::create_client;
let 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."); let response2 = client .reply(response, "What can you do?".to_string(), 0) .expect("An error has occured."); println!("{}", response2.candidates.unwrap()[0].content); ```