Add Auth for WebPage and APIs
This commit is contained in:
parent
e6b87f89ec
commit
5e6d0e0ee6
27 changed files with 15384 additions and 1720 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { Message } from '@/components/ChatWindow';
|
||||
import { getApiUrl, post } from './api';
|
||||
|
||||
export const getSuggestions = async (chatHisory: Message[]) => {
|
||||
const chatModel = localStorage.getItem('chatModel');
|
||||
|
|
@ -7,12 +8,9 @@ export const getSuggestions = async (chatHisory: Message[]) => {
|
|||
const customOpenAIKey = localStorage.getItem('openAIApiKey');
|
||||
const customOpenAIBaseURL = localStorage.getItem('openAIBaseURL');
|
||||
|
||||
const res = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/suggestions`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
const data = await post<{ suggestions: string[] }>(
|
||||
getApiUrl('/suggestions'),
|
||||
{
|
||||
chatHistory: chatHisory,
|
||||
chatModel: {
|
||||
provider: chatModelProvider,
|
||||
|
|
@ -22,10 +20,8 @@ export const getSuggestions = async (chatHisory: Message[]) => {
|
|||
customOpenAIBaseURL,
|
||||
}),
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
const data = (await res.json()) as { suggestions: string[] };
|
||||
}
|
||||
);
|
||||
|
||||
return data.suggestions;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue