perplexica/ui/lib/actions.ts

23 lines
650 B
TypeScript
Raw Normal View History

2024-05-18 07:40:39 +00:00
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;
};