user can send message without defining an api key
This commit is contained in:
@@ -842,7 +842,7 @@ export default function ChatBOX(props: {
|
|||||||
></textarea>
|
></textarea>
|
||||||
<button
|
<button
|
||||||
className="disabled:line-through disabled:bg-slate-500 rounded m-1 p-1 border-2 bg-cyan-400 hover:bg-cyan-600"
|
className="disabled:line-through disabled:bg-slate-500 rounded m-1 p-1 border-2 bg-cyan-400 hover:bg-cyan-600"
|
||||||
disabled={showGenerating || !chatStore.apiKey}
|
disabled={showGenerating}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
send(inputMsg, true);
|
send(inputMsg, true);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -240,12 +240,15 @@ class Chat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const headers: Record<string, string> = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
};
|
||||||
|
if (this.OPENAI_API_KEY) {
|
||||||
|
headers["Authorization"] = `Bearer ${this.OPENAI_API_KEY}`;
|
||||||
|
}
|
||||||
return fetch(this.apiEndpoint, {
|
return fetch(this.apiEndpoint, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers,
|
||||||
Authorization: `Bearer ${this.OPENAI_API_KEY}`,
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify(body),
|
body: JSON.stringify(body),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user