-
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.
- Loading branch information
1 parent
089dc01
commit 17149f0
Showing
9 changed files
with
41 additions
and
70 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
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
import { createServiceRoleClient } from "@/utils/supabase/server"; | ||
import { OpenAI } from "openai"; | ||
|
||
export async function initClients() { | ||
try { | ||
const supabase = createServiceRoleClient(); | ||
const openai = new OpenAI({ | ||
apiKey: process.env.OPENAI_API_KEY | ||
}); | ||
return { supabase, openai }; | ||
} catch (error) { | ||
console.error("Error initializing clients:", error); | ||
throw new Error("Failed to initialize clients"); | ||
} | ||
} | ||
|
||
// retrieve assistant from database | ||
export async function getAssistant(supabase: ReturnType<typeof createServiceRoleClient>) { | ||
const { data, error } = await supabase | ||
.from("assistants") | ||
.select("*") | ||
.eq("name", "StudyHelper") | ||
.single(); | ||
|
||
if (error) { | ||
console.error("Error fetching assistant:", error); | ||
throw new Error("Assistant not found"); | ||
} | ||
|
||
return data; | ||
} |