enzostvs HF Staff commited on
Commit
5d41540
·
1 Parent(s): 82dad97

fix model called

Browse files
components/editor/ask-ai/index.tsx CHANGED
@@ -107,6 +107,8 @@ export function AskAI({
107
 
108
  const result = await callAiFollowUp(
109
  prompt,
 
 
110
  previousPrompt,
111
  selectedElementHtml
112
  );
@@ -121,10 +123,16 @@ export function AskAI({
121
  setPrompt("");
122
  }
123
  } else if (isFollowUp && pages.length > 1 && isSameHtml) {
124
- const result = await callAiNewPage(prompt, currentPage.path, [
125
- ...(previousPrompts ?? []),
126
- ...(htmlHistory?.map((h) => h.prompt) ?? []),
127
- ]);
 
 
 
 
 
 
128
  if (result?.error) {
129
  handleError(result.error, result.message);
130
  return;
@@ -137,6 +145,8 @@ export function AskAI({
137
  } else {
138
  const result = await callAiNewProject(
139
  prompt,
 
 
140
  redesignMarkdown,
141
  handleThink,
142
  () => {
 
107
 
108
  const result = await callAiFollowUp(
109
  prompt,
110
+ model,
111
+ provider,
112
  previousPrompt,
113
  selectedElementHtml
114
  );
 
123
  setPrompt("");
124
  }
125
  } else if (isFollowUp && pages.length > 1 && isSameHtml) {
126
+ const result = await callAiNewPage(
127
+ prompt,
128
+ model,
129
+ provider,
130
+ currentPage.path,
131
+ [
132
+ ...(previousPrompts ?? []),
133
+ ...(htmlHistory?.map((h) => h.prompt) ?? []),
134
+ ]
135
+ );
136
  if (result?.error) {
137
  handleError(result.error, result.message);
138
  return;
 
145
  } else {
146
  const result = await callAiNewProject(
147
  prompt,
148
+ model,
149
+ provider,
150
  redesignMarkdown,
151
  handleThink,
152
  () => {
hooks/useCallAi.ts CHANGED
@@ -1,6 +1,5 @@
1
  import { useState, useRef } from "react";
2
  import { toast } from "sonner";
3
- import { useLocalStorage } from "react-use";
4
  import { MODELS } from "@/lib/providers";
5
  import { Page } from "@/types";
6
 
@@ -27,11 +26,9 @@ export const useCallAi = ({
27
  setisAiWorking,
28
  }: UseCallAiProps) => {
29
  const audio = useRef<HTMLAudioElement | null>(null);
30
- const [provider] = useLocalStorage("provider", "auto");
31
- const [model] = useLocalStorage("model", MODELS[0].value);
32
  const [controller, setController] = useState<AbortController | null>(null);
33
 
34
- const callAiNewProject = async (prompt: string, redesignMarkdown?: string, handleThink?: (think: string) => void, onFinishThink?: () => void) => {
35
  if (isAiWorking) return;
36
  if (!redesignMarkdown && !prompt.trim()) return;
37
 
@@ -134,7 +131,7 @@ export const useCallAi = ({
134
  }
135
  };
136
 
137
- const callAiNewPage = async (prompt: string, currentPagePath: string, previousPrompts?: string[]) => {
138
  if (isAiWorking) return;
139
  if (!prompt.trim()) return;
140
 
@@ -240,7 +237,7 @@ export const useCallAi = ({
240
  }
241
  };
242
 
243
- const callAiFollowUp = async (prompt: string, previousPrompt: string, selectedElementHtml?: string) => {
244
  if (isAiWorking) return;
245
  if (!prompt.trim()) return;
246
 
 
1
  import { useState, useRef } from "react";
2
  import { toast } from "sonner";
 
3
  import { MODELS } from "@/lib/providers";
4
  import { Page } from "@/types";
5
 
 
26
  setisAiWorking,
27
  }: UseCallAiProps) => {
28
  const audio = useRef<HTMLAudioElement | null>(null);
 
 
29
  const [controller, setController] = useState<AbortController | null>(null);
30
 
31
+ const callAiNewProject = async (prompt: string, model: string | undefined, provider: string | undefined, redesignMarkdown?: string, handleThink?: (think: string) => void, onFinishThink?: () => void) => {
32
  if (isAiWorking) return;
33
  if (!redesignMarkdown && !prompt.trim()) return;
34
 
 
131
  }
132
  };
133
 
134
+ const callAiNewPage = async (prompt: string, model: string | undefined, provider: string | undefined, currentPagePath: string, previousPrompts?: string[]) => {
135
  if (isAiWorking) return;
136
  if (!prompt.trim()) return;
137
 
 
237
  }
238
  };
239
 
240
+ const callAiFollowUp = async (prompt: string, model: string | undefined, provider: string | undefined, previousPrompt: string, selectedElementHtml?: string) => {
241
  if (isAiWorking) return;
242
  if (!prompt.trim()) return;
243