messiasads commited on
Commit
11afaf3
·
1 Parent(s): aaa67c2

adjust model initialization

Browse files
Files changed (1) hide show
  1. components/editor/ask-ai/index.tsx +7 -1
components/editor/ask-ai/index.tsx CHANGED
@@ -54,7 +54,12 @@ export function AskAI({
54
  const [hasAsked, setHasAsked] = useState(false);
55
  const [previousPrompt, setPreviousPrompt] = useState("");
56
  const [provider, setProvider] = useLocalStorage("provider", "auto");
57
- const [model, setModel] = useLocalStorage("model", localStorage.getItem("openai_model") || MODELS[0].value);
 
 
 
 
 
58
  const [openProvider, setOpenProvider] = useState(false);
59
  const [providerError, setProviderError] = useState("");
60
  const [think, setThink] = useState<string | undefined>(undefined);
@@ -150,6 +155,7 @@ export function AskAI({
150
  errorMsg = errorJson?.error || errorJson?.message || errorMsg;
151
  } catch (e) {
152
  // fallback: try to read as text
 
153
  try {
154
  errorMsg = await request.text();
155
  } catch {}
 
54
  const [hasAsked, setHasAsked] = useState(false);
55
  const [previousPrompt, setPreviousPrompt] = useState("");
56
  const [provider, setProvider] = useLocalStorage("provider", "auto");
57
+ const [model, setModel] = useLocalStorage(
58
+ "model",
59
+ typeof window !== "undefined"
60
+ ? localStorage.getItem("openai_model") || MODELS[0].value
61
+ : MODELS[0].value
62
+ );
63
  const [openProvider, setOpenProvider] = useState(false);
64
  const [providerError, setProviderError] = useState("");
65
  const [think, setThink] = useState<string | undefined>(undefined);
 
155
  errorMsg = errorJson?.error || errorJson?.message || errorMsg;
156
  } catch (e) {
157
  // fallback: try to read as text
158
+ console.error("Error parsing AI response:", e);
159
  try {
160
  errorMsg = await request.text();
161
  } catch {}