Skip to content

Commit 8048b28

Browse files
authored
Rename OneShot to Ask, update Black style (#1191)
* Rename OneShot to Ask * Formatting changes from new black version
1 parent 457c4d2 commit 8048b28

File tree

11 files changed

+54
-56
lines changed

11 files changed

+54
-56
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
exclude: '^tests/snapshots/'
22
repos:
33
- repo: https://github.com/pre-commit/pre-commit-hooks
4-
rev: v4.4.0
4+
rev: v4.5.0
55
hooks:
66
- id: check-yaml
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.0.289
10+
rev: v0.1.14
1111
hooks:
1212
- id: ruff
1313
- repo: https://github.com/psf/black
14-
rev: 23.9.1
14+
rev: 24.1.0
1515
hooks:
1616
- id: black
1717
- repo: https://github.com/pre-commit/mirrors-prettier
18-
rev: v3.0.3
18+
rev: v4.0.0-alpha.8
1919
hooks:
2020
- id: prettier
2121
types_or: [css, javascript, ts, tsx, html]

app/backend/approaches/approach.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,18 @@ def serialize_for_results(self) -> dict[str, Any]:
4040
"sourcefile": self.sourcefile,
4141
"oids": self.oids,
4242
"groups": self.groups,
43-
"captions": [
44-
{
45-
"additional_properties": caption.additional_properties,
46-
"text": caption.text,
47-
"highlights": caption.highlights,
48-
}
49-
for caption in self.captions
50-
]
51-
if self.captions
52-
else [],
43+
"captions": (
44+
[
45+
{
46+
"additional_properties": caption.additional_properties,
47+
"text": caption.text,
48+
"highlights": caption.highlights,
49+
}
50+
for caption in self.captions
51+
]
52+
if self.captions
53+
else []
54+
),
5355
}
5456

5557
@classmethod

app/backend/approaches/chatreadretrieveread.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717

1818
class ChatReadRetrieveReadApproach(ChatApproach):
19-
2019
"""
2120
A multi-step approach that first uses OpenAI to turn the user's question into a search query,
2221
then uses Azure AI Search to retrieve relevant documents, and then sends the conversation history,
@@ -68,8 +67,7 @@ async def run_until_final_call(
6867
overrides: dict[str, Any],
6968
auth_claims: dict[str, Any],
7069
should_stream: Literal[False],
71-
) -> tuple[dict[str, Any], Coroutine[Any, Any, ChatCompletion]]:
72-
...
70+
) -> tuple[dict[str, Any], Coroutine[Any, Any, ChatCompletion]]: ...
7371

7472
@overload
7573
async def run_until_final_call(
@@ -78,8 +76,7 @@ async def run_until_final_call(
7876
overrides: dict[str, Any],
7977
auth_claims: dict[str, Any],
8078
should_stream: Literal[True],
81-
) -> tuple[dict[str, Any], Coroutine[Any, Any, AsyncStream[ChatCompletionChunk]]]:
82-
...
79+
) -> tuple[dict[str, Any], Coroutine[Any, Any, AsyncStream[ChatCompletionChunk]]]: ...
8380

8481
async def run_until_final_call(
8582
self,

app/backend/approaches/chatreadretrievereadvision.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919

2020
class ChatReadRetrieveReadVisionApproach(ChatApproach):
21-
2221
"""
2322
A multi-step approach that first uses OpenAI to turn the user's question into a search query,
2423
then uses Azure AI Search to retrieve relevant documents, and then sends the conversation history,

app/frontend/src/components/GPT4VSettings/GPT4VSettings.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export const GPT4VSettings = ({ updateGPT4VInputs, updateUseGPT4V, isUseGPT4V, g
3838
{useGPT4V && (
3939
<Dropdown
4040
selectedKey={vectorFieldOption}
41-
className={styles.oneshotSettingsSeparator}
4241
label="GPT-4 Turbo with Vision Inputs"
4342
options={[
4443
{

app/frontend/src/components/VectorSettings/VectorSettings.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export const VectorSettings = ({ updateRetrievalMode, updateVectorFields, showIm
5454
return (
5555
<Stack className={styles.container} tokens={{ childrenGap: 10 }}>
5656
<Dropdown
57-
className={styles.oneshotSettingsSeparator}
5857
label="Retrieval mode"
5958
options={[
6059
{ key: "hybrid", text: "Vectors + Text (Hybrid)", selected: retrievalMode == RetrievalMode.Hybrid, data: RetrievalMode.Hybrid },

app/frontend/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const router = createHashRouter([
5151
},
5252
{
5353
path: "qa",
54-
lazy: () => import("./pages/oneshot/OneShot")
54+
lazy: () => import("./pages/ask/Ask")
5555
},
5656
{
5757
path: "*",

app/frontend/src/pages/oneshot/OneShot.module.css renamed to app/frontend/src/pages/ask/Ask.module.css

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
.oneshotContainer {
1+
.askContainer {
22
display: flex;
33
flex: 1;
44
flex-direction: column;
55
align-items: center;
66
}
77

8-
.oneshotTopSection {
8+
.askTopSection {
99
display: flex;
1010
flex-direction: column;
1111
align-items: center;
1212
width: 100%;
1313
}
1414

15-
.oneshotBottomSection {
15+
.askBottomSection {
1616
display: flex;
1717
flex: 1;
1818
flex-wrap: wrap;
@@ -22,40 +22,40 @@
2222
margin-top: 20px;
2323
}
2424

25-
.oneshotTitle {
25+
.askTitle {
2626
font-size: 4rem;
2727
font-weight: 600;
2828
margin-top: 130px;
2929
}
3030

3131
@media only screen and (max-width: 800px) {
32-
.oneshotTitle {
32+
.askTitle {
3333
font-size: 3rem;
3434
font-weight: 600;
3535
margin-top: 0;
3636
}
3737
}
3838

39-
.oneshotQuestionInput {
39+
.askQuestionInput {
4040
max-width: 800px;
4141
width: 100%;
4242
padding-left: 10px;
4343
padding-right: 10px;
4444
}
4545

46-
.oneshotAnswerContainer {
46+
.askAnswerContainer {
4747
max-width: 800px;
4848
width: 100%;
4949
padding-left: 10px;
5050
padding-right: 10px;
5151
}
5252

53-
.oneshotAnalysisPanel {
53+
.askAnalysisPanel {
5454
width: 600px;
5555
margin-left: 20px;
5656
}
5757

58-
.oneshotSettingsSeparator {
58+
.askSettingsSeparator {
5959
margin-top: 15px;
6060
}
6161

app/frontend/src/pages/oneshot/OneShot.tsx renamed to app/frontend/src/pages/ask/Ask.tsx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useEffect, useRef, useState } from "react";
22
import { Checkbox, Panel, DefaultButton, Spinner, TextField, SpinButton, IDropdownOption, Dropdown } from "@fluentui/react";
33

4-
import styles from "./OneShot.module.css";
4+
import styles from "./Ask.module.css";
55

66
import { askApi, configApi, ChatAppResponse, ChatAppRequest, RetrievalMode, VectorFieldOptions, GPT4VInput } from "../../api";
77
import { Answer, AnswerError } from "../../components/Answer";
@@ -175,11 +175,11 @@ export function Component(): JSX.Element {
175175
};
176176

177177
return (
178-
<div className={styles.oneshotContainer}>
179-
<div className={styles.oneshotTopSection}>
178+
<div className={styles.askContainer}>
179+
<div className={styles.askTopSection}>
180180
<SettingsButton className={styles.settingsButton} onClick={() => setIsConfigPanelOpen(!isConfigPanelOpen)} />
181-
<h1 className={styles.oneshotTitle}>Ask your data</h1>
182-
<div className={styles.oneshotQuestionInput}>
181+
<h1 className={styles.askTitle}>Ask your data</h1>
182+
<div className={styles.askQuestionInput}>
183183
<QuestionInput
184184
placeholder="Example: Does my plan cover annual eye exams?"
185185
disabled={isLoading}
@@ -188,11 +188,11 @@ export function Component(): JSX.Element {
188188
/>
189189
</div>
190190
</div>
191-
<div className={styles.oneshotBottomSection}>
191+
<div className={styles.askBottomSection}>
192192
{isLoading && <Spinner label="Generating answer" />}
193193
{!lastQuestionRef.current && <ExampleList onExampleClicked={onExampleClicked} useGPT4V={useGPT4V} />}
194194
{!isLoading && answer && !error && (
195-
<div className={styles.oneshotAnswerContainer}>
195+
<div className={styles.askAnswerContainer}>
196196
<Answer
197197
answer={answer}
198198
isStreaming={false}
@@ -203,13 +203,13 @@ export function Component(): JSX.Element {
203203
</div>
204204
)}
205205
{error ? (
206-
<div className={styles.oneshotAnswerContainer}>
206+
<div className={styles.askAnswerContainer}>
207207
<AnswerError error={error.toString()} onRetry={() => makeApiRequest(lastQuestionRef.current)} />
208208
</div>
209209
) : null}
210210
{activeAnalysisPanelTab && answer && (
211211
<AnalysisPanel
212-
className={styles.oneshotAnalysisPanel}
212+
className={styles.askAnalysisPanel}
213213
activeCitation={activeCitation}
214214
onActiveTabChanged={x => onToggleTab(x)}
215215
citationHeight="600px"
@@ -229,34 +229,34 @@ export function Component(): JSX.Element {
229229
isFooterAtBottom={true}
230230
>
231231
<TextField
232-
className={styles.oneshotSettingsSeparator}
232+
className={styles.askSettingsSeparator}
233233
defaultValue={promptTemplate}
234234
label="Override prompt template"
235235
multiline
236236
autoAdjustHeight
237237
onChange={onPromptTemplateChange}
238238
/>
239239
<SpinButton
240-
className={styles.oneshotSettingsSeparator}
240+
className={styles.askSettingsSeparator}
241241
label="Retrieve this many search results:"
242242
min={1}
243243
max={50}
244244
defaultValue={retrieveCount.toString()}
245245
onChange={onRetrieveCountChange}
246246
/>
247-
<TextField className={styles.oneshotSettingsSeparator} label="Exclude category" onChange={onExcludeCategoryChanged} />
247+
<TextField className={styles.askSettingsSeparator} label="Exclude category" onChange={onExcludeCategoryChanged} />
248248

249249
{showSemanticRankerOption && (
250250
<Checkbox
251-
className={styles.oneshotSettingsSeparator}
251+
className={styles.askSettingsSeparator}
252252
checked={useSemanticRanker}
253253
label="Use semantic ranker for retrieval"
254254
onChange={onUseSemanticRankerChange}
255255
/>
256256
)}
257257

258258
<Checkbox
259-
className={styles.oneshotSettingsSeparator}
259+
className={styles.askSettingsSeparator}
260260
checked={useSemanticCaptions}
261261
label="Use query-contextual summaries instead of whole documents"
262262
onChange={onUseSemanticCaptionsChange}
@@ -284,7 +284,7 @@ export function Component(): JSX.Element {
284284

285285
{useLogin && (
286286
<Checkbox
287-
className={styles.oneshotSettingsSeparator}
287+
className={styles.askSettingsSeparator}
288288
checked={useOidSecurityFilter || requireAccessControl}
289289
label="Use oid security filter"
290290
disabled={!isLoggedIn(client) || requireAccessControl}
@@ -293,7 +293,7 @@ export function Component(): JSX.Element {
293293
)}
294294
{useLogin && (
295295
<Checkbox
296-
className={styles.oneshotSettingsSeparator}
296+
className={styles.askSettingsSeparator}
297297
checked={useGroupsSecurityFilter || requireAccessControl}
298298
label="Use groups security filter"
299299
disabled={!isLoggedIn(client) || requireAccessControl}
@@ -306,4 +306,4 @@ export function Component(): JSX.Element {
306306
);
307307
}
308308

309-
Component.displayName = "OneShot";
309+
Component.displayName = "Ask";

docs/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ The UI provides a "Developer Settings" menu for customizing the approaches, like
7575
Those settings are passed in the "context" field of the request to the backend, and are not saved permanently.
7676
However, if you find a setting that you do want to make permanent, there are two approaches:
7777

78-
1. Change the defaults in the frontend. You'll find the defaults in `Chat.tsx` and `OneShot.tsx` (for Ask). For example, this line of code sets the default retrieval mode to Hybrid:
78+
1. Change the defaults in the frontend. You'll find the defaults in `Chat.tsx` and `Ask.tsx`. For example, this line of code sets the default retrieval mode to Hybrid:
7979

8080
```typescript
8181
const [retrievalMode, setRetrievalMode] = useState<RetrievalMode>(RetrievalMode.Hybrid);

0 commit comments

Comments
 (0)