File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -407,7 +407,10 @@ export async function POST(request: Request) {
407407
408408 // Trigger initial deployments - await to ensure it completes
409409 try {
410- const origin = new URL ( request . url ) . origin ;
410+ let origin = new URL ( request . url ) . origin ;
411+ if ( / ^ h t t p s : \/ \/ ( l o c a l h o s t | 1 2 7 \. 0 \. 0 \. 1 | \[ : : 1 \] ) / i. test ( origin ) ) {
412+ origin = origin . replace ( / ^ h t t p s : / i, "http:" ) ;
413+ }
411414 console . log ( `[Initial Deploy] Triggering for ${ repoFullName } at ${ origin } /api/deployments/initial` ) ;
412415
413416 const initialDeployResponse = await fetch ( `${ origin } /api/deployments/initial` , {
Original file line number Diff line number Diff line change @@ -609,7 +609,11 @@ function getInternalApiBaseUrl(): string {
609609 if ( candidate ?. trim ( ) ) {
610610 const url = candidate . trim ( ) ;
611611 // Ensure URL has protocol
612- const withProtocol = / ^ h t t p s ? : \/ \/ / i. test ( url ) ? url : `https://${ url } ` ;
612+ let withProtocol = / ^ h t t p s ? : \/ \/ / i. test ( url ) ? url : `https://${ url } ` ;
613+ // Normalize local URLs to use HTTP instead of HTTPS to avoid local SSL handshake errors
614+ if ( / ^ h t t p s : \/ \/ ( l o c a l h o s t | 1 2 7 \. 0 \. 0 \. 1 | \[ : : 1 \] ) / i. test ( withProtocol ) ) {
615+ withProtocol = withProtocol . replace ( / ^ h t t p s : / i, "http:" ) ;
616+ }
613617 return withProtocol . replace ( / \/ $ / , "" ) ;
614618 }
615619 }
Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ export async function callWithFoundryKnowledgeBase(
2121 `${ projectEndpoint } /openai/deployments/${ deployment } /chat/completions` +
2222 `?api-version=2025-01-01-preview` ;
2323
24+ console . log ( `[foundry-kb] calling → ${ url } ` ) ;
25+ console . log ( `[foundry-kb] knowledge base: ${ knowledgeBase } | search endpoint: ${ openAiEndpoint } ` ) ;
26+
2427 try {
2528 const res = await fetch ( url , {
2629 method : "POST" ,
@@ -51,14 +54,21 @@ export async function callWithFoundryKnowledgeBase(
5154
5255 if ( ! res . ok ) {
5356 const errBody = await res . text ( ) . catch ( ( ) => "" ) ;
54- console . warn ( "[foundry-kb] data_sources call failed:" , res . status , errBody ) ;
57+ console . warn ( "[foundry-kb] ❌ failed:" , res . status , errBody ) ;
5558 return null ;
5659 }
5760
5861 const json = await res . json ( ) ;
62+ const citations = json . choices ?. [ 0 ] ?. message ?. context ?. citations ?? [ ] ;
63+ console . log ( `[foundry-kb] ✅ grounded — ${ citations . length } citation(s) from knowledge base` ) ;
64+ if ( citations . length > 0 ) {
65+ citations . forEach ( ( c : any , i : number ) => {
66+ console . log ( ` [${ i + 1 } ] ${ c . title ?? c . filepath ?? "untitled" } ` ) ;
67+ } ) ;
68+ }
5969 return ( json . choices ?. [ 0 ] ?. message ?. content as string ) ?? null ;
6070 } catch ( err ) {
61- console . warn ( "[foundry-kb] data_sources call error:" , err ) ;
71+ console . warn ( "[foundry-kb] ❌ error:" , err ) ;
6272 return null ;
6373 }
6474}
You can’t perform that action at this time.
0 commit comments