@@ -114,11 +114,17 @@ async function main() {
114114
115115 const { configJson, prompt } = await loadConfigFrom ( loadFrom ) ;
116116
117- const ConfigSchema = z . object ( {
118- model : z . string ( ) ,
119- provider : z . enum ( PROVIDERS_OR_POLICIES ) ,
120- servers : z . array ( ServerConfigSchema ) ,
121- } ) ;
117+ const ConfigSchema = z
118+ . object ( {
119+ model : z . string ( ) ,
120+ provider : z . enum ( PROVIDERS_OR_POLICIES ) . optional ( ) ,
121+ endpointUrl : z . string ( ) . optional ( ) ,
122+ apiKey : z . string ( ) . optional ( ) ,
123+ servers : z . array ( ServerConfigSchema ) ,
124+ } )
125+ . refine ( ( data ) => data . provider !== undefined || data . endpointUrl !== undefined , {
126+ message : "At least one of 'provider' or 'endpointUrl' is required" ,
127+ } ) ;
122128
123129 let config : z . infer < typeof ConfigSchema > ;
124130 try {
@@ -129,13 +135,24 @@ async function main() {
129135 process . exit ( 1 ) ;
130136 }
131137
132- const agent = new Agent ( {
133- provider : config . provider ,
134- model : config . model ,
135- apiKey : process . env . HF_TOKEN ?? "" ,
136- servers : config . servers ,
137- prompt,
138- } ) ;
138+ const agent = new Agent (
139+ config . endpointUrl
140+ ? {
141+ endpointUrl : config . endpointUrl ,
142+ model : config . model ,
143+ apiKey : config . apiKey ?? process . env . API_KEY ?? process . env . HF_TOKEN ,
144+ servers : config . servers ,
145+ prompt,
146+ }
147+ : {
148+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
149+ provider : config . provider ! ,
150+ model : config . model ,
151+ apiKey : config . apiKey ?? process . env . API_KEY ?? process . env . HF_TOKEN ,
152+ servers : config . servers ,
153+ prompt,
154+ }
155+ ) ;
139156
140157 if ( command === "serve" ) {
141158 error ( `Serve is not implemented yet, coming soon!` ) ;
0 commit comments