-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show available models list in settings (#83)
* create utils/models * add availableModels prop * fetch models on startup and key change * remove default model list * consider model fetch for loading spinner * clearer description * remove accidental debug delay * Update src/components/App.tsx * Update src/components/App.tsx * Update src/components/App.tsx * distinguish isAnythingSaving and isAnythingLoading --------- Co-authored-by: t11s <[email protected]>
- Loading branch information
1 parent
54ebe4c
commit 1dfc26f
Showing
4 changed files
with
82 additions
and
6 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,28 @@ | ||
export function getAvailableModels(apiKey: string): Promise<string[]> { | ||
return new Promise(async (resolve, reject) => { | ||
try { | ||
const response = await fetch("https://api.openai.com/v1/models", { | ||
method: "GET", | ||
headers: { | ||
Authorization: `Bearer ${apiKey}`, | ||
}, | ||
}) | ||
const data = await response.json(); | ||
resolve(data.data.map((model: any) => model.id).sort()); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
}); | ||
}; | ||
|
||
export function getAvailableChatModels(apiKey: string): Promise<string[]> { | ||
return new Promise((resolve, reject) => { | ||
getAvailableModels(apiKey) | ||
.then((models) => { | ||
resolve(models.filter((model) => model.startsWith("gpt-"))); | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
}); | ||
}; |
1dfc26f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
flux – ./
flux-paradigm-operations.vercel.app
flux.paradigm.xyz
flux-git-main-paradigm-operations.vercel.app