File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/api/Providers/special Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import fetch from "#root/src/api/fetch.js";
44const getHeaders = ( apiKey ) => {
55 return {
66 "Content-Type" : "application/json" ,
7+ "Accept" : "*/*" ,
78 Authorization : apiKey ? `Bearer ${ apiKey } ` : undefined ,
89 } ;
910} ;
@@ -32,12 +33,20 @@ export const CustomOpenAIProvider = {
3233 // eslint-disable-next-line no-empty
3334 } catch { }
3435
35- const api_url = url + "/chat/completions" ;
36+ const api_url = url . endsWith ( "/chat/completions" ) ? url : url + "/chat/completions" ;
3637 const model = options . model ;
3738 const api_key = options . apiKey || apiData . apiKey ;
3839 const config = apiData . config || { } ;
3940
4041 chat = messages_to_json ( chat ) ;
42+
43+ let headers = {
44+ ...getHeaders ( api_key ) ,
45+ ...config ?. HEADERS ,
46+ } ;
47+
48+ delete config . HEADERS ;
49+
4150 let body = {
4251 messages : chat ,
4352 stream : true ,
@@ -49,7 +58,7 @@ export const CustomOpenAIProvider = {
4958 api_url ,
5059 {
5160 method : "POST" ,
52- headers : getHeaders ( api_key ) ,
61+ headers : headers ,
5362 body : JSON . stringify ( body ) ,
5463 } ,
5564 { timeout : 0 } // disable timeout
You can’t perform that action at this time.
0 commit comments