Skip to content

Commit

Permalink
Moving public prefix within try-catch block (#486)
Browse files Browse the repository at this point in the history
* Moving public prefix to block

* Path prefix config addition

* Abstracting Cloud share APIs

* Addressing public attributes for OSS

* Update backend/backend/public_urls.py

Signed-off-by: Chandrasekharan M <[email protected]>

---------

Signed-off-by: Chandrasekharan M <[email protected]>
Co-authored-by: Chandrasekharan M <[email protected]>
Co-authored-by: Rahul Johny <[email protected]>
  • Loading branch information
3 people authored Jul 16, 2024
1 parent cf3c480 commit 142174c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion backend/backend/public_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

path_prefix = settings.PATH_PREFIX
api_path_prefix = settings.API_DEPLOYMENT_PATH_PREFIX
share_path_prefix = settings.PUBLIC_PATH_PREFIX

urlpatterns = [
path(f"{path_prefix}/", include("account.urls")),
Expand Down Expand Up @@ -51,6 +50,8 @@
import pluggable_apps.platform_admin.urls # noqa # pylint: disable=unused-import
import pluggable_apps.public_shares_share_controller.urls # noqa # pylint: disable=unused-import

share_path_prefix = settings.PUBLIC_PATH_PREFIX

urlpatterns += [
path(f"{path_prefix}/", include("pluggable_apps.platform_admin.urls")),
# Public Sharing
Expand Down
19 changes: 14 additions & 5 deletions frontend/src/components/helpers/custom-tools/CustomToolsHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import { useSocketCustomToolStore } from "../../../store/socket-custom-tool";
import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader";
import { useTokenUsageStore } from "../../../store/token-usage-store";

let shareManagerToolSource;
try {
shareManagerToolSource =
require("../../../plugins/prompt-studio-public-share/helpers/PublicShareAPIs").shareManagerToolSource;
} catch (err) {
// Do nothing, Not-found Page will be triggered.
}
function CustomToolsHelper() {
const [isLoading, setIsLoading] = useState(true);
const { id } = useParams();
Expand Down Expand Up @@ -82,11 +89,13 @@ function CustomToolsHelper() {
.then((res) => {
const data = res?.data;
updatedCusTool["llmProfiles"] = data;
const reqOpsShare = {
method: "GET",
url: `/api/v1/unstract/${sessionDetails?.orgId}/share-manager/tool-source/?tool_id=${id}`,
};
return handleApiRequest(reqOpsShare);
if (shareManagerToolSource) {
const reqOpsShare = {
method: "GET",
url: shareManagerToolSource(id, sessionDetails?.orgId),
};
return handleApiRequest(reqOpsShare);
}
})
.then((res) => {
const data = res?.data;
Expand Down

0 comments on commit 142174c

Please sign in to comment.