File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -24,18 +24,18 @@ const __dirname = path.dirname(__filename);
2424const openAIApiKey = process . env . OPENAI_API_KEY ;
2525const dbDir = process . env . SQLITE_DB_DIR || __dirname ; // Default to current dir if not set
2626
27- if ( ! openAIApiKey ) {
28- console . error ( "Error: OPENAI_API_KEY environment variable is not set." ) ;
29- process . exit ( 1 ) ;
30- }
3127if ( ! fs . existsSync ( dbDir ) ) {
3228 console . warn ( `Warning: SQLITE_DB_DIR (${ dbDir } ) does not exist. Databases may not be found.` ) ;
3329 process . exit ( 1 ) ;
3430}
3531
36- const openai = new OpenAI ( {
37- apiKey : openAIApiKey ,
38- } ) ;
32+ const strictMode = process . env . STRICT_MODE === 'true' ;
33+ if ( strictMode ) {
34+ if ( ! openAIApiKey ) {
35+ console . error ( "Error: OPENAI_API_KEY environment variable is not set." ) ;
36+ process . exit ( 1 ) ;
37+ }
38+ }
3939
4040export interface QueryResult {
4141 chunk_id: string ;
@@ -48,6 +48,9 @@ export interface QueryResult {
4848
4949async function createEmbeddings ( text : string ) : Promise < number [ ] > {
5050 try {
51+ const openai = new OpenAI ( {
52+ apiKey : openAIApiKey ,
53+ } ) ;
5154 console . error ( "Calling OpenAI embeddings API..." ) ;
5255 const startTime = Date . now ( ) ;
5356 const response = await openai . embeddings . create ( {
@@ -189,7 +192,7 @@ server.tool(
189192
190193// --- Transport Setup ---
191194async function main ( ) {
192- const transport_type = process . env . TRANSPORT_TYPE || 'sse ' ;
195+ const transport_type = process . env . TRANSPORT_TYPE || 'http ' ;
193196
194197 if ( transport_type === 'stdio' ) {
195198 // Stdio transport for direct communication
You can’t perform that action at this time.
0 commit comments