forked from Stability-AI/StableStudio
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* mobile ui updates * fixes sidebar btn * return if null * mobile input blur * handle mobile enter key * new convo name * new delete mechanism * test height * revert * change padding * remove overflow * check relative * padding * done * retry * test * test * should work now * test * test * more * max h * revert * done
- Loading branch information
1 parent
9a48248
commit 7810a3e
Showing
8 changed files
with
197 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { OpenAIModel, OpenAIModelID, OpenAIModels } from "@/types"; | ||
|
||
export const config = { | ||
runtime: "edge" | ||
}; | ||
|
||
const handler = async (req: Request): Promise<Response> => { | ||
try { | ||
const { key } = (await req.json()) as { | ||
key: string; | ||
}; | ||
|
||
const response = await fetch("https://api.openai.com/v1/models", { | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: `Bearer ${key ? key : process.env.OPENAI_API_KEY}` | ||
} | ||
}); | ||
|
||
if (response.status !== 200) { | ||
throw new Error("OpenAI API returned an error"); | ||
} | ||
|
||
const json = await response.json(); | ||
|
||
const models: OpenAIModel[] = json.data | ||
.map((model: any) => { | ||
for (const [key, value] of Object.entries(OpenAIModelID)) { | ||
if (value === model.id) { | ||
return { | ||
id: model.id, | ||
name: OpenAIModels[value].name | ||
}; | ||
} | ||
} | ||
}) | ||
.filter(Boolean); | ||
|
||
return new Response(JSON.stringify(models), { status: 200 }); | ||
} catch (error) { | ||
console.error(error); | ||
return new Response("Error", { status: 500 }); | ||
} | ||
}; | ||
|
||
export default handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.