The LLM is still in early access but you can sign up for the waitlist here

Open palm-chat in Script Kit

let { GoogleAuth } = await import("google-auth-library");
let { DiscussServiceClient } = await import("@google-ai/generativelanguage");
import "@johnlindquist/kit";
const MODEL_NAME = "models/chat-bison-001";
const API_KEY = await env("PALM_API_KEY", {
hint: `Signup for waitlist here <a href="https://developers.generativeai.google/">here</a>`,
});
const client = new DiscussServiceClient({
authClient: new GoogleAuth().fromAPIKey(API_KEY),
});
const config = {
model: MODEL_NAME,
temperature: 0.75,
candidateCount: 1,
top_k: 40,
top_p: 0.95,
};
const chatHistory = [];
const generateText = async (text) => {
chatHistory.push({ content: text });
const response = await client.generateMessage({
...config,
prompt: {
context: "You are a funny and helpful assistant.",
messages: chatHistory,
},
});
log(response);
log(response[0].filters);
if (response[0].filters.length > 0) {
return `The model has rejected your input. Reason: ${response[0].filters[0].reason}`;
} else {
chatHistory.push({ content: response[0].candidates[0].content });
return response[0].candidates[0].content;
}
};
await chat({
onSubmit: async (input) => {
setLoading(true);
try {
const response = await generateText(input);
let message = md(response);
chat.addMessage("");
chat.setMessage(-1, message);
} catch (e) {
console.log(e);
chat.addMessage("");
chat.setMessage(-1, md("Error: " + e.message));
}
setLoading(false);
},
});