chatbottesttwo

This commit is contained in:
Flatlogic Bot 2025-05-24 21:07:40 +00:00
parent 3e434c13ff
commit 01a2285d0c
2 changed files with 10 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -36,7 +36,7 @@ export const aiPrompt = createAsyncThunk(
'openai/aiPrompt',
async (data: any, { rejectWithValue }) => {
try {
return await axios.post('/openai/create_widget', data);
return await axios.post('/api/openai/create_widget', data);
} catch (error) {
if (!error.response) {
throw error;
@ -48,9 +48,14 @@ export const aiPrompt = createAsyncThunk(
export const askGpt = createAsyncThunk(
'openai/askGpt',
async (prompt: string, { rejectWithValue }) => {
async (prompt: string, { rejectWithValue, getState }) => {
try {
const response = await axios.post('/openai/ask-gpt', { prompt });
const token = (getState() as any).auth.token;
const response = await axios.post(
'/api/openai/ask-gpt',
{ prompt },
{ headers: { Authorization: `Bearer ${token}` } }
);
return response.data;
} catch (error) {
if (!error.response) {