Skip to content

Commit bd54595

Browse files
authored
Merge branch 'develop' into fb-LEAP-1292
2 parents b1569f1 + d98964a commit bd54595

File tree

20 files changed

+101
-149
lines changed

20 files changed

+101
-149
lines changed

docs/source/guide/prompts_keys.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,14 @@ To add a custom model, enter the following:
113113
* The endpoint URL for the model. For example, `https://my.openai.endpoint.com/v1`
114114
* An API key to access the model. An API key is tied to a specific account, but the access is shared within the org if added. (Optional)
115115
* An auth token to access the model API. An auth token provides API access at the server level. (Optional)
116+
117+
### Example
118+
119+
1. Setup [Ollama](https://ollama.com/), e.g. `ollama run llama3.2`
120+
2. [Verify your local OpenAI-compatible API is working](https://ollama.com/blog/openai-compatibility), e.g. `http://localhost:11434/v1`
121+
3. Create an externally facing endpoint, e.g. `https://my.openai.endpoint.com/v1` -> `http://localhost:11434/v1`
122+
4. Add connection to Label Studio:
123+
- Name: `llama3.2` (must match the model name in Ollama)
124+
- Endpoint: `https://my.openai.endpoint.com/v1` (note `v1` suffix is required)
125+
- API key: `ollama` (default)
126+
- Auth token: empty

label_studio/core/feature_flags/stale_feature_flags.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'fflag_fix_front_lsdv_4600_lead_time_27072023_short': False,
77
'fflag_feat_front_lops_e_10_updated_ux_short': False,
88
'fflag_fix_front_lsdv_4988_dynamic_no_label_120523_short': True,
9-
'fflag_feat_back_lsdv_5035_use_created_at_from_draft_for_annotation_256052023_short': True,
9+
'fflag_fix_back_lsdv_4648_annotator_filter_29052023_short': True,
1010
'ff_back_dev_4664_remove_storage_file_on_export_delete_29032023_short': False,
1111
'fflag_feat_front_lops_86_datasets_storage_edit_short': False,
1212
'fflag_fix_back_lsdv_4929_limit_exports_10042023_short': True,

label_studio/tasks/api.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import logging
44

55
import drf_yasg.openapi as openapi
6-
from core.feature_flags import flag_set
76
from core.mixins import GetParentObjectMixin
87
from core.permissions import ViewClassPermission, all_permissions
98
from core.utils.common import DjangoFilterDescriptionInspector
@@ -573,9 +572,7 @@ def perform_create(self, ser):
573572
if draft.task_id != task.id or not draft.has_permission(user) or draft.user_id != user.id:
574573
raise PermissionDenied(f'You have no permission to draft id:{draft_id}')
575574

576-
if draft is not None and flag_set(
577-
'fflag_feat_back_lsdv_5035_use_created_at_from_draft_for_annotation_256052023_short', user='auto'
578-
):
575+
if draft is not None:
579576
# if the annotation will be created from draft - get created_at from draft to keep continuity of history
580577
extra_args['draft_created_at'] = draft.created_at
581578

web/apps/labelstudio/src/pages/Organization/PeoplePage/@components/auth-token-settings/index.tsx

Lines changed: 0 additions & 54 deletions
This file was deleted.

web/apps/labelstudio/src/pages/Organization/PeoplePage/PeoplePage.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { PeopleList } from "./PeopleList";
1616
import "./PeoplePage.scss";
1717
import { SelectedUser } from "./SelectedUser";
1818
import { TokenSettingsModal } from "@humansignal/core/blocks/TokenSettingsModal";
19+
import { useToast } from "@humansignal/ui";
1920
import { debounce } from "@humansignal/core/lib/utils/debounce";
2021

2122
const InvitationModal = ({ link }) => {
@@ -51,7 +52,9 @@ const InvitationModal = ({ link }) => {
5152
export const PeoplePage = () => {
5253
const api = useAPI();
5354
const inviteModal = useRef();
55+
const apiSettingsModal = useRef();
5456
const config = useConfig();
57+
const toast = useToast();
5558
const [selectedUser, setSelectedUser] = useState(null);
5659

5760
const [link, setLink] = useState();
@@ -121,13 +124,20 @@ export const PeoplePage = () => {
121124
() => ({
122125
title: "API Token Settings",
123126
style: { width: 480 },
124-
body: () => <TokenSettingsModal />,
127+
body: () => (
128+
<TokenSettingsModal
129+
onSaved={() => {
130+
toast.show({ message: "API Token settings saved" });
131+
apiSettingsModal.current?.close();
132+
}}
133+
/>
134+
),
125135
}),
126136
[],
127137
);
128138

129139
const showApiTokenSettingsModal = useCallback(() => {
130-
inviteModal.current = modal(apiTokensSettingsModalProps);
140+
apiSettingsModal.current = modal(apiTokensSettingsModalProps);
131141
__lsa("organization.token_settings");
132142
}, [inviteModalProps, link]);
133143

web/dist/apps/labelstudio/543.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/dist/apps/labelstudio/543.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/dist/apps/labelstudio/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/dist/apps/labelstudio/main.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/dist/apps/labelstudio/vendor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/dist/apps/labelstudio/vendor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"message": "feat: OPTIC-1643: Copy Data Manager Quick View link to annotation or region (#7122)",
3-
"commit": "b0783d85eb641cd7e5986ea12b085ff172473d27",
4-
"date": "2025-02-26T13:45:32.000Z",
2+
"message": "chore: LEAP-1293: Remove fflag_feat_back_lsdv_5035_use_created_at_fro… (#7135)",
3+
"commit": "5a180200585ac61e43e3e9b3aa19ed5512783bfc",
4+
"date": "2025-02-27T14:35:14.000Z",
55
"branch": "develop"
66
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"message": "feat: OPTIC-1643: Copy Data Manager Quick View link to annotation or region (#7122)",
3-
"commit": "b0783d85eb641cd7e5986ea12b085ff172473d27",
4-
"date": "2025-02-26T13:45:32.000Z",
2+
"message": "chore: LEAP-1293: Remove fflag_feat_back_lsdv_5035_use_created_at_fro… (#7135)",
3+
"commit": "5a180200585ac61e43e3e9b3aa19ed5512783bfc",
4+
"date": "2025-02-27T14:35:14.000Z",
55
"branch": "develop"
66
}

web/dist/libs/editor/version.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"message": "feat: OPTIC-1643: Copy Data Manager Quick View link to annotation or region (#7122)",
3-
"commit": "b0783d85eb641cd7e5986ea12b085ff172473d27",
4-
"date": "2025-02-26T13:45:32.000Z",
2+
"message": "chore: LEAP-1293: Remove fflag_feat_back_lsdv_5035_use_created_at_fro… (#7135)",
3+
"commit": "5a180200585ac61e43e3e9b3aa19ed5512783bfc",
4+
"date": "2025-02-27T14:35:14.000Z",
55
"branch": "develop"
66
}
Lines changed: 43 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,84 @@
1-
import { Form, Input, Toggle } from "apps/labelstudio/src/components/Form";
21
import { useAtomValue } from "jotai";
3-
import { formDataToJPO } from "@humansignal/core/lib/utils/helpers";
4-
import { saveSettingsAtom, settingsAtom } from "@humansignal/core/pages/AccountSettings/atoms";
2+
import { settingsAtom, TOKEN_SETTINGS_KEY } from "@humansignal/core/pages/AccountSettings/atoms";
3+
import { queryClientAtom } from "jotai-tanstack-query";
4+
5+
import { Form, Input, Toggle } from "apps/labelstudio/src/components/Form";
6+
import { Button } from "apps/labelstudio/src/components/Button/Button";
57
import type { AuthTokenSettings } from "@humansignal/core/pages/AccountSettings/types";
6-
import { useRef } from "react";
7-
import { debounce } from "@humansignal/core/lib/utils/debounce";
8+
import { type ChangeEvent, useState } from "react";
89

910
export const TokenSettingsModal = ({
1011
showTTL,
12+
onSaved,
1113
}: {
1214
showTTL?: boolean;
15+
onSaved?: () => void;
1316
}) => {
1417
const settings = useAtomValue(settingsAtom);
15-
const formRef = useRef<Form>();
16-
const { mutate: saveSettings } = useAtomValue(saveSettingsAtom);
17-
const onSubmit = debounce(() => {
18-
const form = formRef.current.formElement.current as HTMLFormElement;
19-
const data = formDataToJPO(new FormData(form));
20-
const body = {
21-
api_tokens_enabled: data.api_tokens_enabled === "on",
22-
legacy_api_tokens_enabled: data.legacy_api_tokens_enabled === "on",
23-
} satisfies Partial<AuthTokenSettings>;
24-
saveSettings(body);
25-
});
18+
if (!settings.isSuccess || settings.isError || "error" in settings.data) {
19+
return <div>Error loading settings.</div>;
20+
}
2621
return (
27-
<Form ref={formRef} onChange={onSubmit}>
22+
<TokenSettingsModalView
23+
key={settings.data?.api_tokens_enabled}
24+
settings={settings.data}
25+
showTTL={showTTL}
26+
onSaved={onSaved}
27+
/>
28+
);
29+
};
30+
31+
function TokenSettingsModalView({
32+
settings,
33+
showTTL,
34+
onSaved,
35+
}: { settings: AuthTokenSettings; showTTL?: boolean; onSaved?: () => void }) {
36+
const [enableTTL, setEnableTTL] = useState(settings.api_tokens_enabled);
37+
const queryClient = useAtomValue(queryClientAtom);
38+
const reloadSettings = () => {
39+
queryClient.invalidateQueries({ queryKey: [TOKEN_SETTINGS_KEY] });
40+
onSaved?.();
41+
};
42+
return (
43+
<Form action="accessTokenUpdateSettings" onSubmit={reloadSettings}>
2844
<Form.Row columnCount={1}>
2945
<Toggle
3046
label="Personal Access Tokens"
3147
name="api_tokens_enabled"
3248
description="Enable increased token authentication security"
33-
checked={settings.data?.api_tokens_enabled ?? false}
49+
checked={settings.api_tokens_enabled ?? false}
50+
onChange={(e: ChangeEvent<HTMLInputElement>) => setEnableTTL(e.target.checked)}
3451
/>
3552
</Form.Row>
3653
<Form.Row columnCount={1}>
3754
<Toggle
3855
label="Legacy Tokens"
3956
name="legacy_api_tokens_enabled"
4057
description="Enable legacy access tokens"
41-
checked={settings.data?.legacy_api_tokens_enabled}
58+
checked={settings.legacy_api_tokens_enabled ?? true}
4259
/>
4360
</Form.Row>
4461
{showTTL === true && (
4562
<Form.Row columnCount={1}>
4663
<Input
47-
name="time_to_live"
64+
name="api_token_ttl_days"
4865
label="Personal Access Token Time-to-Live"
4966
description="The number of days, after creation, that the token will be valid for. After this time period a user will need to create a new access token"
5067
labelProps={{
5168
description:
5269
"The number of days, after creation, that the token will be valid for. After this time period a user will need to create a new access token",
5370
}}
54-
disabled={!settings.data?.api_tokens_enabled}
71+
disabled={!enableTTL}
5572
type="number"
5673
min={10}
5774
max={365}
58-
value={settings.data?.time_to_live ?? 30}
75+
value={settings.api_token_ttl_days ?? 30}
5976
/>
6077
</Form.Row>
6178
)}
79+
<Form.Actions>
80+
<Button type="submit">Save</Button>
81+
</Form.Actions>
6282
</Form>
6383
);
64-
};
84+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.success {
2+
color: green;
3+
display: flex;
4+
gap: 8px;
5+
align-items: center;
6+
justify-content: center;
7+
}
8+
9+
.success svg {
10+
width: 16px;
11+
height: 16px;
12+
}
Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,23 @@
11
import { API } from "apps/labelstudio/src/providers/ApiProvider";
2-
import { atomWithMutation, atomWithQuery, queryClientAtom } from "jotai-tanstack-query";
2+
import { atomWithQuery } from "jotai-tanstack-query";
33

44
type AuthTokenSettings = {
55
api_tokens_enabled: boolean;
66
legacy_api_tokens_enabled: boolean;
7-
time_to_live: number;
7+
api_token_ttl_days: number;
88
};
99

1010
export const TOKEN_SETTINGS_KEY = "api-settings";
1111

1212
export const settingsAtom = atomWithQuery(() => ({
1313
queryKey: [TOKEN_SETTINGS_KEY],
1414
async queryFn() {
15-
const result = await API.invoke("accessTokenSettings");
15+
const result = await API.invoke<AuthTokenSettings>("accessTokenSettings");
1616

1717
if (!result.$meta.ok) {
1818
return { error: true };
1919
}
2020

21-
return result as AuthTokenSettings;
21+
return result;
2222
},
2323
}));
24-
25-
export const saveSettingsAtom = atomWithMutation((get) => {
26-
const queryClient = get(queryClientAtom);
27-
return {
28-
mutationKey: ["api-settings-save"],
29-
async mutationFn(settings: Partial<AuthTokenSettings>) {
30-
const result = await API.invoke(
31-
"accessTokenUpdateSettings",
32-
{},
33-
{
34-
body: settings,
35-
},
36-
);
37-
38-
if (!result.$meta.ok) {
39-
throw new Error(result.error);
40-
}
41-
42-
return result as Partial<AuthTokenSettings>;
43-
},
44-
async onMutate(settings: Partial<AuthTokenSettings>) {
45-
await queryClient.cancelQueries({ queryKey: [TOKEN_SETTINGS_KEY] });
46-
const previousSettings = queryClient.getQueryData([TOKEN_SETTINGS_KEY]) as AuthTokenSettings;
47-
queryClient.setQueryData(
48-
[TOKEN_SETTINGS_KEY],
49-
(old: AuthTokenSettings[]) => ({ ...previousSettings, ...settings }) as AuthTokenSettings,
50-
);
51-
52-
return { previousSettings };
53-
},
54-
onError: (err, newTodo, context) => {
55-
queryClient.setQueryData([TOKEN_SETTINGS_KEY], context?.previousSettings);
56-
},
57-
onSettled() {
58-
queryClient.invalidateQueries({ queryKey: [TOKEN_SETTINGS_KEY] });
59-
},
60-
};
61-
});
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export type AuthTokenSettings = {
22
api_tokens_enabled: boolean;
33
legacy_api_tokens_enabled: boolean;
4-
time_to_live: number;
4+
api_token_ttl_days: number;
55
};

web/libs/datamanager/src/sdk/lsf-utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { APIAnnotation, APIPrediction, APITask, LSFAnnotation, LSFTaskData } from "../types/Task";
2-
import { FF_LSDV_5035, isFF } from "../utils/feature-flags";
32

43
/**
54
* Converts the task from the server format to the
@@ -30,7 +29,7 @@ export const taskToLSFormat = (task: APITask): LSFTaskData | void => {
3029
};
3130

3231
export const annotationToLSF = (annotation: APIAnnotation) => {
33-
const createdDate = isFF(FF_LSDV_5035) ? annotation.draft_created_at || annotation.created_at : annotation.created_at;
32+
const createdDate = annotation.draft_created_at || annotation.created_at;
3433

3534
return {
3635
...annotation,

web/libs/datamanager/src/utils/feature-flags.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ export const FF_LSDV_4620_3_ML = "fflag_fix_front_lsdv_4620_memory_leaks_100723_
4242
*/
4343
export const FF_LSDV_4711 = "fflag_fix_all_lsdv_4711_cors_errors_accessing_task_data_short";
4444

45-
/**
46-
* Allow the ability to filter annotations by their original created_at timestamp
47-
*/
48-
export const FF_LSDV_5035 = "fflag_feat_back_lsdv_5035_use_created_at_from_draft_for_annotation_256052023_short";
49-
5045
/**
5146
* Updated UX with improved accessibility
5247
*/

0 commit comments

Comments
 (0)