push
This commit is contained in:
@@ -9,6 +9,7 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
const { key } = (await req.json()) as {
|
||||
key: string;
|
||||
};
|
||||
console.log("key", key);
|
||||
|
||||
const response = await fetch("https://api.openai.com/v1/models", {
|
||||
headers: {
|
||||
@@ -23,6 +24,8 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
|
||||
const json = await response.json();
|
||||
|
||||
console.log("json", json);
|
||||
|
||||
const models: OpenAIModel[] = json.data
|
||||
.map((model: any) => {
|
||||
for (const [key, value] of Object.entries(OpenAIModelID)) {
|
||||
@@ -36,6 +39,8 @@ const handler = async (req: Request): Promise<Response> => {
|
||||
})
|
||||
.filter(Boolean);
|
||||
|
||||
console.log("models", models);
|
||||
|
||||
return new Response(JSON.stringify(models), { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
|
||||
+4
-4
@@ -155,6 +155,7 @@ export default function Home() {
|
||||
};
|
||||
|
||||
const fetchModels = async (key: string) => {
|
||||
console.log(key);
|
||||
const response = await fetch("/api/models", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
@@ -170,6 +171,8 @@ export default function Home() {
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(response.json());
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!data) {
|
||||
@@ -189,6 +192,7 @@ export default function Home() {
|
||||
const handleApiKeyChange = (apiKey: string) => {
|
||||
setApiKey(apiKey);
|
||||
localStorage.setItem("apiKey", apiKey);
|
||||
fetchModels(apiKey);
|
||||
};
|
||||
|
||||
const handleExportConversations = () => {
|
||||
@@ -280,10 +284,6 @@ export default function Home() {
|
||||
}
|
||||
}, [selectedConversation]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchModels(apiKey);
|
||||
}, [apiKey]);
|
||||
|
||||
useEffect(() => {
|
||||
const theme = localStorage.getItem("theme");
|
||||
if (theme) {
|
||||
|
||||
Reference in New Issue
Block a user