Skip to content

Commit 5ec82fd

Browse files
committed
fix: use app name for request origin
1 parent 549ea4c commit 5ec82fd

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

packages/compass-assistant/src/compass-assistant-provider.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export const CompassAssistantProvider = registerCompassPlugin(
280280
initialProps.chat ??
281281
new Chat({
282282
transport: new DocsProviderTransport({
283+
appName: initialProps.appNameForPrompt,
283284
instructions: buildConversationInstructionsPrompt({
284285
target: initialProps.appNameForPrompt,
285286
}),

packages/compass-assistant/src/docs-provider-transport.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,21 @@ export function shouldExcludeMessage({ metadata }: AssistantMessage) {
1717

1818
export class DocsProviderTransport implements ChatTransport<AssistantMessage> {
1919
private model: LanguageModel;
20+
private appName: string;
2021
private instructions: string;
2122

2223
constructor({
2324
instructions,
2425
model,
26+
appName,
2527
}: {
2628
instructions: string;
2729
model: LanguageModel;
30+
appName: string;
2831
}) {
2932
this.instructions = instructions;
3033
this.model = model;
34+
this.appName = appName;
3135
}
3236

3337
static emptyStream = new ReadableStream<UIMessageChunk>({
@@ -60,6 +64,9 @@ export class DocsProviderTransport implements ChatTransport<AssistantMessage> {
6064
model: this.model,
6165
messages: convertToModelMessages(filteredMessages),
6266
abortSignal: abortSignal,
67+
headers: {
68+
'X-Request-Origin': this.appName,
69+
},
6370
providerOptions: {
6471
openai: {
6572
instructions: this.instructions,

0 commit comments

Comments
 (0)