27 lines
799 B
TypeScript
27 lines
799 B
TypeScript
import { Message } from '@/components/ChatWindow';
|
|
import { getApiUrl, post } from './api';
|
|
|
|
export const getSuggestions = async (chatHisory: Message[]) => {
|
|
const chatModel = localStorage.getItem('chatModel');
|
|
const chatModelProvider = localStorage.getItem('chatModelProvider');
|
|
|
|
const customOpenAIKey = localStorage.getItem('openAIApiKey');
|
|
const customOpenAIBaseURL = localStorage.getItem('openAIBaseURL');
|
|
|
|
const data = await post<{ suggestions: string[] }>(
|
|
getApiUrl('/suggestions'),
|
|
{
|
|
chatHistory: chatHisory,
|
|
chatModel: {
|
|
provider: chatModelProvider,
|
|
model: chatModel,
|
|
...(chatModelProvider === 'custom_openai' && {
|
|
customOpenAIKey,
|
|
customOpenAIBaseURL,
|
|
}),
|
|
},
|
|
}
|
|
);
|
|
|
|
return data.suggestions;
|
|
};
|