feat(app): add suggestion generation

This commit is contained in:
ItzCrazyKns 2024-05-18 13:10:39 +05:30
parent 68b595023e
commit 3bfaf9be28
No known key found for this signature in database
GPG key ID: 8162927C7CCE3065
4 changed files with 53 additions and 3 deletions

22
ui/lib/actions.ts Normal file
View file

@ -0,0 +1,22 @@
import { Message } from '@/components/ChatWindow';
export const getSuggestions = async (chatHisory: Message[]) => {
const chatModel = localStorage.getItem('chatModel');
const chatModelProvider = localStorage.getItem('chatModelProvider');
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/suggestions`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
chat_history: chatHisory,
chat_model: chatModel,
chat_model_provider: chatModelProvider,
}),
});
const data = (await res.json()) as { suggestions: string[] };
return data.suggestions;
};