Skip to content

Commit

Permalink
Fixed tool export with a default llm profile, bumped structure tool v…
Browse files Browse the repository at this point in the history
…ersion's SDK to 0.15.1
  • Loading branch information
chandrasekharan-zipstack committed Mar 13, 2024
1 parent f26634a commit 538f331
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
8 changes: 5 additions & 3 deletions backend/prompt_studio/prompt_studio_core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions backend/prompt_studio/prompt_studio_core/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import uuid

from account.models import User
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from prompt_studio.prompt_studio_core.exceptions import DefaultProfileError
from utils.models.base_model import BaseModel


Expand Down Expand Up @@ -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 DefaultProfileError
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from unstract.tool_registry.dto import Properties, Spec, Tool

from .constants import JsonSchemaKey
from .exceptions import InternalError, ProfileErrors, ToolSaveError
from .exceptions import InternalError, ToolSaveError
from .models import PromptStudioRegistry
from .serializers import PromptStudioRegistrySerializer

Expand Down Expand Up @@ -180,11 +180,10 @@ def frame_export_json(
llm = ""
embedding_model = ""

default_llm_profile = tool.get_default_llm_profile() # type: ignore
for 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_profile

vector_db = str(prompt.profile_manager.vector_store.id)
embedding_model = str(prompt.profile_manager.embedding_model.id)
Expand Down
2 changes: 1 addition & 1 deletion tools/structure/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Add your dependencies here

# Required for all unstract tools
unstract-sdk~=0.15.0
unstract-sdk~=0.15.1
2 changes: 1 addition & 1 deletion tools/structure/src/config/properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 538f331

Please sign in to comment.