Skip to content

Commit ff87160

Browse files
committed
Set custom User-Agent for HuggingChat requests
Adds a 'User-Agent: huggingchat' header to OpenAI API requests when the PUBLIC_APP_NAME is 'HuggingChat', ensuring proper identification of requests from HuggingChat.
1 parent 9f06190 commit ff87160

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib/server/endpoints/openai/endpointOai.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ export async function endpointOai(
105105
const openai = new OpenAI({
106106
apiKey: apiKey || "sk-",
107107
baseURL,
108-
defaultHeaders,
108+
defaultHeaders: {
109+
...(config.PUBLIC_APP_NAME === "HuggingChat" && { "User-Agent": "huggingchat" }),
110+
...defaultHeaders,
111+
},
109112
defaultQuery,
110113
fetch: customFetch,
111114
});

0 commit comments

Comments
 (0)