You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let{ GoogleAuth }=awaitimport("google-auth-library");let{ DiscussServiceClient }=awaitimport("@google-ai/generativelanguage");import"@johnlindquist/kit";constMODEL_NAME="models/chat-bison-001";constAPI_KEY=awaitenv("PALM_API_KEY",{hint: `Signup for waitlist here <a href="https://developers.generativeai.google/">here</a>`,});constclient=newDiscussServiceClient({authClient: newGoogleAuth().fromAPIKey(API_KEY),});constconfig={model: MODEL_NAME,temperature: 0.75,candidateCount: 1,top_k: 40,top_p: 0.95,};constchatHistory=[];constgenerateText=async(text)=>{chatHistory.push({content: text});constresponse=awaitclient.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});returnresponse[0].candidates[0].content;}};awaitchat({onSubmit: async(input)=>{setLoading(true);try{constresponse=awaitgenerateText(input);letmessage=md(response);chat.addMessage("");chat.setMessage(-1,message);}catch(e){console.log(e);chat.addMessage("");chat.setMessage(-1,md("Error: "+e.message));}setLoading(false);},});
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
The LLM is still in early access but you can sign up for the waitlist here
Open palm-chat in Script Kit
Beta Was this translation helpful? Give feedback.
All reactions