Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

Fixed undefined displayed when default llm is deleted (#62)

jagadeeswaran-zipstack36cc50913470
diff --git a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
index dc5e2f887..ce527e894 100644
--- a/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
+++ b/frontend/src/components/custom-tools/prompt-card/PromptCard.jsx
@@ -116,16 +116,6 @@ function PromptCard({
return { value: outputTypeData[item] };
});
setEnforceTypeList(dropdownList1);
-
- const llmProfileId = promptDetails?.profile_manager;
- if (!llmProfileId) {
- setPage(0);
- return;
- }
- const index = llmProfiles.findIndex(
- (item) => item?.profile_id === llmProfileId
- );
- setPage(index + 1);
}, []);
useEffect(() => {
@@ -197,6 +187,27 @@ function PromptCard({
[]
);
+ useEffect(() => {
+ const isProfilePresent = llmProfiles.some(
+ (profile) => profile.profile_id === selectedLlmProfileId
+ );
+
+ // If selectedLlmProfileId is not present, set it to null
+ if (!isProfilePresent) {
+ setSelectedLlmProfileId(null);
+ }
+
+ const llmProfileId = promptDetails?.profile_manager;
+ if (!llmProfileId) {
+ setPage(0);
+ return;
+ }
+ const index = llmProfiles.findIndex(
+ (item) => item?.profile_id === llmProfileId
+ );
+ setPage(index + 1);
+ }, [llmProfiles]);
+
const handlePageLeft = () => {
if (page <= 1) {
return;
@@ -764,17 +775,22 @@ function PromptCard({
</div>
<div className="prompt-card-llm-profiles">
{llmProfiles?.length > 0 &&
- promptDetails?.profile_manager?.length > 0 ? (
+ promptDetails?.profile_manager?.length > 0 &&
+ selectedLlmProfileId ? (
<div>
- <Tag>{llmProfiles[page - 1]?.llm}</Tag>
- <Tag>{llmProfiles[page - 1]?.vector_store}</Tag>
- <Tag>{llmProfiles[page - 1]?.embedding_model}</Tag>
- <Tag>{llmProfiles[page - 1]?.x2text}</Tag>
- <Tag>{`${llmProfiles[page - 1]?.chunk_size}/${
- llmProfiles[page - 1]?.chunk_overlap
- }/${llmProfiles[page - 1]?.retrieval_strategy}/${
- llmProfiles[page - 1]?.similarity_top_k
- }/${llmProfiles[page - 1]?.section}`}</Tag>
+ {llmProfiles
+ .filter(
+ (profile) => profile.profile_id === selectedLlmProfileId
+ )
+ .map((profile, index) => (
+ <div key={index}>
+ <Tag>{profile.llm}</Tag>
+ <Tag>{profile.vector_store}</Tag>
+ <Tag>{profile.embedding_model}</Tag>
+ <Tag>{profile.x2text}</Tag>
+ <Tag>{`${profile.chunk_size}/${profile.chunk_overlap}/${profile.retrieval_strategy}/${profile.similarity_top_k}/${profile.section}`}</Tag>
+ </div>
+ ))}
</div>
) : (
<div>