@@ -142,6 +142,8 @@ async function embed_with_provider(
142142 return await emb_local ( t , s ) ;
143143 case "synthetic" :
144144 return gen_syn_emb ( t , s ) ;
145+ case "siray" :
146+ return await emb_siray ( t , s ) ;
145147 default :
146148 throw new Error ( `Unknown embedding provider: ${ provider } ` ) ;
147149 }
@@ -400,6 +402,31 @@ async function emb_aws(t: string, s: string): Promise<number[]> {
400402 }
401403}
402404
405+ async function emb_siray ( t : string , s : string ) : Promise < number [ ] > {
406+ if ( ! env . siray_key ) throw new Error ( "Siray key missing" ) ;
407+ const m = get_model ( s , "siray" ) ;
408+
409+ // Use direct fetch since we might need custom handling or just to be safe
410+ // adapting from emb_openai but with siray vars
411+ const r = await fetchWithTimeout (
412+ `${ env . siray_base_url . replace ( / \/ $ / , "" ) } /embeddings` ,
413+ {
414+ method : "POST" ,
415+ headers : {
416+ "content-type" : "application/json" ,
417+ authorization : `Bearer ${ env . siray_key } ` ,
418+ } ,
419+ body : JSON . stringify ( {
420+ input : t ,
421+ model : m ,
422+ // Siray docs didn't specify dimensions support for all models, assume standard if compatible
423+ } ) ,
424+ } ,
425+ ) ;
426+ if ( ! r . ok ) throw new Error ( `Siray: ${ r . status } ` ) ;
427+ return ( ( await r . json ( ) ) as any ) . data [ 0 ] . embedding ;
428+ }
429+
403430async function emb_local ( t : string , s : string ) : Promise < number [ ] > {
404431 if ( ! env . local_model_path ) {
405432 console . error ( "[EMBED] Local model missing, using synthetic" ) ;
@@ -686,6 +713,16 @@ export const getEmbeddingInfo = () => {
686713 ! ! env . AWS_SECRET_ACCESS_KEY ;
687714 i . batch_api = env . embed_mode === "simple" ;
688715 i . model = "amazon.titan-embed-text-v2:0" ;
716+ } else if ( env . emb_kind === "siray" ) {
717+ i . configured = ! ! env . siray_key ;
718+ i . base_url = env . siray_base_url ;
719+ i . models = {
720+ episodic : get_model ( "episodic" , "siray" ) ,
721+ semantic : get_model ( "semantic" , "siray" ) ,
722+ procedural : get_model ( "procedural" , "siray" ) ,
723+ emotional : get_model ( "emotional" , "siray" ) ,
724+ reflective : get_model ( "reflective" , "siray" ) ,
725+ } ;
689726 } else if ( env . emb_kind === "ollama" ) {
690727 i . configured = true ;
691728 i . url = env . ollama_url ;
0 commit comments