11import OpenAI from "openai" ;
22
33const token = process . env [ "GITHUB_TOKEN" ] ;
4- const endpoint = "https://models.inference .ai.azure.com " ;
4+ const endpoint = "https://models.github .ai/inference " ;
55
66/* Pick one of the OpenAI embeddings models from the GitHub Models service */
77const modelName = "text-embedding-3-small" ;
@@ -11,16 +11,16 @@ export async function main() {
1111 const client = new OpenAI ( { baseURL : endpoint , apiKey : token } ) ;
1212
1313 const response = await client . embeddings . create ( {
14- input : [ "first phrase" , "second phrase" , "third phrase" ] ,
15- model : modelName
14+ input : [ "first phrase" , "second phrase" , "third phrase" ] ,
15+ model : modelName
1616 } ) ;
1717
1818 for ( const item of response . data ) {
19- let length = item . embedding . length ;
20- console . log (
21- `data[${ item . index } ]: length=${ length } , ` +
22- `[${ item . embedding [ 0 ] } , ${ item . embedding [ 1 ] } , ` +
23- `..., ${ item . embedding [ length - 2 ] } , ${ item . embedding [ length - 1 ] } ]` ) ;
19+ let length = item . embedding . length ;
20+ console . log (
21+ `data[${ item . index } ]: length=${ length } , ` +
22+ `[${ item . embedding [ 0 ] } , ${ item . embedding [ 1 ] } , ` +
23+ `..., ${ item . embedding [ length - 2 ] } , ${ item . embedding [ length - 1 ] } ]` ) ;
2424 }
2525 console . log ( response . usage ) ;
2626}
0 commit comments