LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
fix: Fixed tool export with a default llm profile (#97)
Chandrasekharan Md6ec2c445b79
diff --git a/backend/prompt_studio/prompt_studio_core/exceptions.py b/backend/prompt_studio/prompt_studio_core/exceptions.pyindex 1d553603f..1d3d1dda2 100644--- a/backend/prompt_studio/prompt_studio_core/exceptions.py+++ b/backend/prompt_studio/prompt_studio_core/exceptions.py@@ -29,9 +29,11 @@ class AnswerFetchError(APIException):class DefaultProfileError(APIException):- status_code = 400- default_detail = "Default profile is not selected. \- Please select one from Profile manager."+ status_code = 500+ default_detail = (+ "Default LLM profile is not configured."+ "Please set an LLM profile as default to continue."+ )class EnvRequired(APIException):diff --git a/backend/prompt_studio/prompt_studio_core/models.py b/backend/prompt_studio/prompt_studio_core/models.pyindex 4dbf94358..9dbda4a6d 100644--- a/backend/prompt_studio/prompt_studio_core/models.py+++ b/backend/prompt_studio/prompt_studio_core/models.py@@ -1,7 +1,9 @@import uuidfrom account.models import User+from django.core.exceptions import ObjectDoesNotExistfrom django.db import models+from prompt_studio.prompt_studio_core.exceptions import DefaultProfileErrorfrom utils.models.base_model import BaseModel@@ -68,3 +70,10 @@ class CustomTool(BaseModel):blank=True,editable=False,)++ # TODO: Add ProfileManager to return type+ def get_default_llm_profile(self): # type: ignore+ try:+ return self.profilemanager_set.filter(is_default=True).first()+ except ObjectDoesNotExist:+ raise DefaultProfileErrordiff --git a/backend/prompt_studio/prompt_studio_registry/prompt_studio_registry_helper.py b/backend/prompt_studio/prompt_studio_registry/prompt_studio_registry_helper.pyindex a2e42b6f9..384573f6f 100644--- a/backend/prompt_studio/prompt_studio_registry/prompt_studio_registry_helper.py+++ b/backend/prompt_studio/prompt_studio_registry/prompt_studio_registry_helper.py@@ -12,7 +12,7 @@ from prompt_studio.prompt_studio_core.prompt_studio_helper import (from unstract.tool_registry.dto import Properties, Spec, Toolfrom .constants import JsonSchemaKey-from .exceptions import InternalError, ProfileErrors, ToolSaveError+from .exceptions import InternalError, ToolSaveErrorfrom .models import PromptStudioRegistryfrom .serializers import PromptStudioRegistrySerializer@@ -180,11 +180,10 @@ class PromptStudioRegistryHelper:llm = ""embedding_model = ""+ default_llm_profile = tool.get_default_llm_profile() # type: ignorefor prompt in prompts:- if not tool.default_profile:- raise ProfileErrors()if not prompt.profile_manager:- prompt.profile_manager = tool.default_profile+ prompt.profile_manager = default_llm_profilevector_db = str(prompt.profile_manager.vector_store.id)embedding_model = str(prompt.profile_manager.embedding_model.id)diff --git a/tools/structure/requirements.txt b/tools/structure/requirements.txtindex e7658f93e..a852e5f35 100644--- a/tools/structure/requirements.txt+++ b/tools/structure/requirements.txt@@ -1,4 +1,4 @@# Add your dependencies here# Required for all unstract tools-unstract-sdk~=0.15.0+unstract-sdk~=0.15.1diff --git a/tools/structure/src/config/properties.json b/tools/structure/src/config/properties.jsonindex e1c52bda3..903a649b4 100644--- a/tools/structure/src/config/properties.json+++ b/tools/structure/src/config/properties.json@@ -2,7 +2,7 @@"schemaVersion": "0.0.1","displayName": "Structure Tool","functionName": "structure_tool",- "toolVersion": "0.0.3",+ "toolVersion": "0.0.4","description": "This is a template tool which can answer set of input prompts designed in the Prompt Studio","input": {"description": "File that needs to be indexed and parsed for answers"