Skip to content

Commit

Permalink
Refactor and add getCommonHeaders function
Browse files Browse the repository at this point in the history
  • Loading branch information
amitjoshi committed Nov 11, 2024
1 parent 6b0b9d6 commit 1e9260c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { ITelemetry } from "../../../../OneDSLoggerTelemetry/telemetry/ITelemetry";
import { getCommonHeaders } from "../../../../services/AuthenticationProvider";
import { ABOUT_PAGE_TYPE, FAQ_PAGE_TYPE, HOME_PAGE_TYPE, INFO_PAGE_TYPE, NL2PAGE_GENERATE_NEW_PAGE, NL2PAGE_REQUEST_FAILED, NL2PAGE_SCENARIO, NL2PAGE_SCOPE} from "../../PowerPagesChatParticipantConstants";
import { VSCODE_EXTENSION_NL2PAGE_REQUEST_FAILED, VSCODE_EXTENSION_NL2PAGE_REQUEST_SUCCESS } from "../../PowerPagesChatParticipantTelemetryConstants";

Expand Down Expand Up @@ -40,10 +41,7 @@ export async function getNL2PageData(aibEndpoint: string, aibToken: string, user

const requestInit: RequestInit = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${aibToken}`
},
headers: getCommonHeaders(aibToken),
body: JSON.stringify(requestBody)
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { ITelemetry } from "../../../../OneDSLoggerTelemetry/telemetry/ITelemetry";
import { NL2SITE_GENERATE_NEW_SITE, NL2SITE_INVALID_RESPONSE, NL2SITE_SCENARIO} from "../../PowerPagesChatParticipantConstants";
import { VSCODE_EXTENSION_NL2SITE_REQUEST_SUCCESS, VSCODE_EXTENSION_NL2SITE_REQUEST_FAILED } from "../../PowerPagesChatParticipantTelemetryConstants";
import { getCommonHeaders } from "../../../../services/AuthenticationProvider";

export async function getNL2SiteData(aibEndpoint: string, aibToken: string, userPrompt: string, sessionId: string, telemetry: ITelemetry) {
const requestBody = {
Expand All @@ -28,10 +29,7 @@ export async function getNL2SiteData(aibEndpoint: string, aibToken: string, user

const requestInit: RequestInit = {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${aibToken}`
},
headers: getCommonHeaders(aibToken),
body: JSON.stringify(requestBody)
};

Expand Down

0 comments on commit 1e9260c

Please sign in to comment.