-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
642fd0b
commit c8b27b4
Showing
7 changed files
with
36 additions
and
33 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export function isValidAPIKey(apiKey: string | null) { | ||
return (apiKey?.length === 51 && apiKey.startsWith("sk-")) || (apiKey?.length === 56 && apiKey.startsWith("sk-proj-")); | ||
return apiKey?.length ?? 0 >= 50; // No idea what Hyperbolic's key spec is, but this is a safe bet. | ||
} |
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 |
---|---|---|
@@ -1,28 +1,24 @@ | ||
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); | ||
} | ||
}); | ||
}; | ||
return new Promise(async (resolve, reject) => { | ||
const models = [ | ||
"Qwen/Qwen2-72B-Instruct", | ||
// "meta-llama/Meta-Llama-3-70B-Instruct", — N completions is broken, get fragments or no response at all. | ||
// "mistralai/Mixtral-8x22B-Instruct-v0.1", — Keep getting 'network error' | ||
"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO", | ||
]; | ||
|
||
resolve(models); | ||
}); | ||
} | ||
|
||
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); | ||
}); | ||
}); | ||
}; | ||
return new Promise((resolve, reject) => { | ||
getAvailableModels(apiKey) | ||
.then((models) => { | ||
resolve(models); | ||
}) | ||
.catch((err) => { | ||
reject(err); | ||
}); | ||
}); | ||
} |