Commit 0a403a5f by Jonathan Thomas

If OpenAI key is set, switch URL automatically back to OpenAI endpoint

parent b261c286
......@@ -12,6 +12,7 @@ All notable changes to **CreatureChat** are documented in this file. The format
### Fixed
- Parse OpenAI JSON error messages, to display a more readable error message
- Remove quotes from CreatureChat API error messages
- If OpenAI key is set, switch URL automatically back to OpenAI endpoint
## [1.0.4] - 2024-05-15
......
......@@ -73,9 +73,12 @@ public class ConfigurationHandler {
// Getters and setters for existing fields
public String getApiKey() { return apiKey; }
public void setApiKey(String apiKey) {
// Update URL if a CreatureChat API key is detected
if (apiKey.startsWith("cc_") && apiKey.length() == 15) {
// Update URL if a CreatureChat API key is detected
setUrl("https://api.creaturechat.com/v1/chat/completions");
} else if (apiKey.startsWith("sk-")) {
// Update URL if a OpenAI API key is detected
setUrl("https://api.openai.com/v1/chat/completions");
}
this.apiKey = apiKey;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment