Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Simple Prompt Studio CRUD functionality #481

Merged
merged 33 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
1df80dc
UI changes for SPS
tahierhussain Jul 11, 2024
1be10ee
Added the SPS APIs to the public urls
tahierhussain Jul 11, 2024
265bdcf
Removed unwanted proxy setup
tahierhussain Jul 11, 2024
8ea5df0
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 11, 2024
9a2514a
Removed usage of arrow function for calling a function with no arguments
tahierhussain Jul 12, 2024
face1be
Merge branch 'main' into simple-prompt-studio-crud
Deepak-Kesavan Jul 15, 2024
c028101
Handled loading icon when document is getting indexed in SPS
tahierhussain Jul 18, 2024
ffa1c2b
Added a new package: react-google-recaptcha
tahierhussain Jul 18, 2024
413c89c
Moved the variable initialization inside the try-catch block
tahierhussain Jul 18, 2024
560b0d1
Added the library for google recaptcha enterprise
tahierhussain Jul 18, 2024
624a100
Modified the reorder logic to support SPS
tahierhussain Jul 18, 2024
3885c7c
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 18, 2024
812978d
Minor changes in reorder helper method
tahierhussain Jul 18, 2024
715a3eb
Renamed 'PromptModel' to 'prompt_model'
tahierhussain Jul 18, 2024
9fc1b74
Minor fix
tahierhussain Jul 18, 2024
f7be1e9
Fixed sonar issue
tahierhussain Jul 18, 2024
06e1f52
Added a new plugin for SPS
tahierhussain Jul 19, 2024
e05cf1f
Minor bug fix in displaying the loader while retrieving the prompt re…
tahierhussain Jul 19, 2024
bc554ec
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 19, 2024
02200de
Removed unwanted raising of the exception
tahierhussain Jul 19, 2024
6011336
Moved the prompt model to the controller
tahierhussain Jul 21, 2024
8ec706b
Added trailing slash to the reorder API
tahierhussain Jul 21, 2024
dc22d92
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 23, 2024
a9be153
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 25, 2024
964be51
Improvements in SPS
tahierhussain Jul 25, 2024
9918296
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 25, 2024
0102a95
Removed google recaptcha dependency
tahierhussain Jul 25, 2024
7575629
Merge branch 'main' into simple-prompt-studio-crud
tahierhussain Jul 25, 2024
1c38b83
Added CSS classes for padding
tahierhussain Jul 26, 2024
11cd25d
Merge branch 'simple-prompt-studio-crud' of github.com:Zipstack/unstr…
tahierhussain Jul 26, 2024
e4ce52a
Merge branch 'main' into simple-prompt-studio-crud
tahierhussain Jul 27, 2024
107d293
Merge branch 'main' of github.com:Zipstack/unstract into simple-promp…
tahierhussain Jul 31, 2024
cf21a39
Removed requirements.txt deletion
tahierhussain Jul 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion backend/backend/public_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

path_prefix = settings.PATH_PREFIX
api_path_prefix = settings.API_DEPLOYMENT_PATH_PREFIX
simple_prompt_studio_path_prefix = settings.SIMPLE_PROMPT_STUDIO_PATH_PREFIX
tahierhussain marked this conversation as resolved.
Show resolved Hide resolved

urlpatterns = [
path(f"{path_prefix}/", include("account.urls")),
Expand All @@ -47,10 +48,37 @@


try:
import pluggable_apps.platform_admin.urls # noqa: F401
import pluggable_apps.platform_admin.urls # noqa # pylint: disable=unused-import

urlpatterns += [
path(f"{path_prefix}/", include("pluggable_apps.platform_admin.urls")),
]
except ImportError:
pass

try:
import pluggable_apps.simple_prompt_studio.sps_document.urls # noqa # pylint: disable=unused-import
import pluggable_apps.simple_prompt_studio.sps_project.urls # noqa # pylint: disable=unused-import
import pluggable_apps.simple_prompt_studio.sps_prompt.urls # noqa # pylint: disable=unused-import
import pluggable_apps.simple_prompt_studio.sps_prompt_output.urls # noqa # pylint: disable=unused-import

urlpatterns += [
path(
f"{path_prefix}/{simple_prompt_studio_path_prefix}/",
include("pluggable_apps.simple_prompt_studio.sps_project.urls"),
),
path(
f"{path_prefix}/{simple_prompt_studio_path_prefix}/",
include("pluggable_apps.simple_prompt_studio.sps_document.urls"),
),
path(
f"{path_prefix}/{simple_prompt_studio_path_prefix}/",
include("pluggable_apps.simple_prompt_studio.sps_prompt.urls"),
),
path(
f"{path_prefix}/{simple_prompt_studio_path_prefix}/",
include("pluggable_apps.simple_prompt_studio.sps_prompt_output.urls"),
),
]
except ImportError:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { PdfViewer } from "../pdf-viewer/PdfViewer";
import { TextViewerPre } from "../text-viewer-pre/TextViewerPre";
import usePostHogEvents from "../../../hooks/usePostHogEvents";

const items = [
let items = [
{
key: "1",
label: "PDF View",
Expand Down Expand Up @@ -92,22 +92,24 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {

useEffect(() => {
if (isSimplePromptStudio) {
items[0] = {
key: "1",
label: (
<Tooltip title="PDF View">
<FilePdfOutlined />
</Tooltip>
),
};
items[1] = {
key: "2",
label: (
<Tooltip title="Raw View">
<FileTextOutlined />
</Tooltip>
),
};
items = [
athul-rs marked this conversation as resolved.
Show resolved Hide resolved
{
key: "1",
label: (
<Tooltip title="PDF View">
<FilePdfOutlined />
</Tooltip>
),
},
{
key: "2",
label: (
<Tooltip title="Raw View">
<FileTextOutlined />
</Tooltip>
),
},
];
}
}, []);

Expand Down Expand Up @@ -172,7 +174,7 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
};

const handleGetDocumentsReq = (getDocsFunc, viewType) => {
getDocsFunc(viewType)
getDocsFunc(details?.tool_id, selectedDoc?.document_id, viewType)
.then((res) => {
const data = res?.data?.data || "";
processGetDocsResponse(data, viewType);
Expand All @@ -185,10 +187,10 @@ function DocumentManager({ generateIndex, handleUpdateTool, handleDocChange }) {
});
};

const getDocuments = async (viewType) => {
const getDocuments = async (toolId, docId, viewType) => {
const requestOptions = {
method: "GET",
url: `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/file/${details?.tool_id}?document_id=${selectedDoc?.document_id}&view_type=${viewType}`,
url: `/api/v1/unstract/${sessionDetails?.orgId}/prompt-studio/file/${toolId}?document_id=${docId}&view_type=${viewType}`,
};

return axiosPrivate(requestOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,13 @@ function DocumentParser({
};

const handleDelete = (promptId) => {
let url = promptUrl(promptId + "/");
if (isSimplePromptStudio) {
url = promptPatchApiSps(promptId);
}
const requestOptions = {
method: "DELETE",
url: promptUrl(promptId + "/"),
url,
headers: {
"X-CSRFToken": sessionDetails?.csrfToken,
},
Expand Down
49 changes: 27 additions & 22 deletions frontend/src/components/custom-tools/prompt-card/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function Header({
singlePassExtractMode,
isSinglePassExtractLoading,
indexDocs,
isSimplePromptStudio,
} = useCustomToolStore();

const [isDisablePrompt, setIsDisablePrompt] = useState(promptDetails?.active);
Expand Down Expand Up @@ -157,30 +158,34 @@ function Header({
<PlayCircleOutlined className="prompt-card-actions-head" />
</Button>
</Tooltip>
<Tooltip title="Run All">
<Button
size="small"
type="text"
className="prompt-card-action-button"
onClick={() => handleRunBtnClick()}
disabled={
(updateStatus?.promptId === promptDetails?.prompt_id &&
updateStatus?.status ===
promptStudioUpdateStatus?.isUpdating) ||
disableLlmOrDocChange?.includes(promptDetails?.prompt_id) ||
indexDocs?.includes(selectedDoc?.document_id)
}
>
<PlayCircleFilled className="prompt-card-actions-head" />
</Button>
</Tooltip>
{!isSimplePromptStudio && (
<Tooltip title="Run All">
<Button
size="small"
type="text"
className="prompt-card-action-button"
onClick={() => handleRunBtnClick()}
tahierhussain marked this conversation as resolved.
Show resolved Hide resolved
disabled={
(updateStatus?.promptId === promptDetails?.prompt_id &&
updateStatus?.status ===
promptStudioUpdateStatus?.isUpdating) ||
disableLlmOrDocChange?.includes(promptDetails?.prompt_id) ||
indexDocs?.includes(selectedDoc?.document_id)
}
>
<PlayCircleFilled className="prompt-card-actions-head" />
</Button>
</Tooltip>
)}
</>
)}
<Checkbox
checked={isDisablePrompt}
className="prompt-card-action-button"
onChange={handleDisablePrompt}
/>
{!isSimplePromptStudio && (
<Checkbox
checked={isDisablePrompt}
className="prompt-card-action-button"
onChange={handleDisablePrompt}
/>
)}
<Divider type="vertical" className="header-delete-divider" />
<ConfirmModal
handleConfirm={() => handleDelete(promptDetails?.prompt_id)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ function PromptCard({
resetInfoMsgs();
handleGetOutput();
handleGetCoverage();
if (isSinglePassExtractLoading) {
return;
}
}, [
selectedLlmProfileId,
selectedDoc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ function PromptCardItems({
};

const getAdapterInfo = async (adapterData) => {
// If simple prompt studio, return early
if (isSimplePromptStudio) {
return;
}

// Update llmProfiles with additional fields
const updatedProfiles = llmProfiles?.map((profile) => {
return { ...getModelOrAdapterId(profile, adapterData), ...profile };
Expand Down Expand Up @@ -233,6 +238,7 @@ function PromptCardItems({
useEffect(() => {
getAdapterInfo(adapters);
}, [llmProfiles, selectedLlmProfileId, enabledProfiles]);

return (
<Card className="prompt-card">
<div className="prompt-card-div prompt-card-bg-col1 prompt-card-rad">
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,4 @@ module.exports = (app) => {
changeOrigin: true,
})
);
app.use(
"/public",
createProxyMiddleware({
target: process.env.REACT_APP_BACKEND_URL,
changeOrigin: true,
})
);
vishnuszipstack marked this conversation as resolved.
Show resolved Hide resolved
};
Loading