mirror of
https://github.com/danielmiessler/fabric
synced 2024-11-10 07:10:31 +00:00
fixed gui again
This commit is contained in:
parent
f30559bc63
commit
8dadd4b8db
@ -134,21 +134,18 @@ async function loadApiKeys() {
|
||||
let keys = { openAIKey: null, claudeKey: null };
|
||||
|
||||
try {
|
||||
// Use fs.promises.readFile and await its result
|
||||
const envContents = await fs.readFile(configPath, { encoding: "utf8" });
|
||||
const openAIMatch = envContents.match(/^OPENAI_API_KEY=(.*)$/m);
|
||||
const claudeMatch = envContents.match(/^CLAUDE_API_KEY=(.*)$/m);
|
||||
|
||||
if (openAIMatch && openAIMatch[1]) {
|
||||
keys.openAIKey = openAIMatch[1];
|
||||
// Initialize your OpenAI client here if necessary
|
||||
}
|
||||
if (claudeMatch && claudeMatch[1]) {
|
||||
keys.claudeKey = claudeMatch[1];
|
||||
// Initialize your Claude client here if necessary
|
||||
claude = new Anthropic({ apiKey: keys.claudeKey });
|
||||
}
|
||||
} catch (error) {
|
||||
// Handle the case where the .env file doesn't exist or can't be read
|
||||
console.error("Could not load API keys:", error);
|
||||
}
|
||||
return keys;
|
||||
@ -338,6 +335,14 @@ async function openaiMessage(system, user, model, event) {
|
||||
}
|
||||
|
||||
async function claudeMessage(system, user, model, event) {
|
||||
if (!claude) {
|
||||
event.reply(
|
||||
"model-response-error",
|
||||
"Claude API key is missing or invalid."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const userMessage = { role: "user", content: user };
|
||||
const systemMessage = system;
|
||||
const response = await claude.messages.create({
|
||||
|
Loading…
Reference in New Issue
Block a user