Skip to content

Commit

Permalink
fix: Model header setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ReinderVosDeWael committed Jul 11, 2024
1 parent c3b2479 commit f7d81c4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion src/routes/api/intake-report/[id]/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { AZURE_FUNCTION_PYTHON_KEY, AZURE_FUNCTION_PYTHON_URL } from "$lib/serve

export async function GET({ request, params, fetch }) {
const id = params.id
logger.info("Getting intake with id ", id)
const model = request.headers.get("X-Model") || "gpt-4o"
logger.info(`Getting intake with id ${id} and model ${model}`)
const headers = new Headers({ "x-functions-key": AZURE_FUNCTION_PYTHON_KEY || "", "X-model": model })
return await fetch(`${AZURE_FUNCTION_PYTHON_URL}/intake-report/${id}`, { headers: headers })
.then(async response => {
Expand Down
52 changes: 27 additions & 25 deletions src/routes/intake/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
})
return
}
isLoading = true
const headers = new Headers()
headers.append("X-model", model)
fetch(`/api/intake-report/${redcapSurveyId}`)
headers.set("X-Model", model)
fetch(`/api/intake-report/${redcapSurveyId}`, { headers })
.then(async response => {
if (!response.ok) {
throw new Error(await response.text())
Expand Down Expand Up @@ -71,30 +72,31 @@
generate a report for.
</p>
<br />
<div class="flex space-x-1">
<label for="redcapSurveyId">MRN</label>
<button class="hover-highlight" on:click={explainMRN} disabled={modalOpen} tabindex="-1">
<QuestionMarkCircleIcon />
</button>
</div>
<form class="space-y-2">
<input class="input w-72" type="number" placeholder="MRN" bind:value={redcapSurveyId} />
<br />
<label>
Model
<br />
<select class="input w-72" bind:value={model}>
{#each LLM_MODELS as model}
<option value={model.tag}>{model.name}</option>
{/each}
</select>
</label>
<br />
<button class="btn variant-filled-primary" on:click={onSubmit} disabled={isLoading}> Submit </button>
</form>

{#if isLoading}
<LoadingBar />
<LoadingBar label="Loading... This may take a while." />
{:else}
<div class="flex space-x-1">
<label for="redcapSurveyId">MRN</label>
<button class="hover-highlight" on:click={explainMRN} disabled={modalOpen} tabindex="-1">
<QuestionMarkCircleIcon />
</button>
</div>

<form class="space-y-2">
<input class="input w-72" type="number" placeholder="MRN" bind:value={redcapSurveyId} />
<br />
<label>
Model
<br />
<select class="input w-72" bind:value={model}>
{#each LLM_MODELS as model}
<option value={model.tag}>{model.name}</option>
{/each}
</select>
</label>
<br />
<button class="btn variant-filled-primary" on:click={onSubmit} disabled={isLoading}> Submit </button>
</form>
{/if}

<style>
Expand Down

0 comments on commit f7d81c4

Please sign in to comment.