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

Prompt studio fixes #503

Merged
merged 3 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def update_or_create_prompt_output(
document_manager = DocumentManager.objects.get(pk=document_id)

for prompt in prompts:
if prompt.prompt_type == PSOMKeys.NOTES or not prompt.active:
if prompt.prompt_type == PSOMKeys.NOTES:
continue

if not is_single_pass_extract:
Expand Down
5 changes: 3 additions & 2 deletions backend/prompt_studio/prompt_studio_registry/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ class ToolSaveError(APIException):
class EmptyToolExportError(APIException):
status_code = 500
default_detail = (
"Empty Prompt Studio project without prompts cannot be exported. "
"Try adding a prompt and executing it."
"Prompt Studio project without prompts cannot be exported. "
"Please ensure there is at least one prompt and "
"it is active before exporting."
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ def frame_export_json(
llm = ""
embedding_model = ""

if not outputs:
raise EmptyToolExportError()

if invalidated_prompts:
raise InValidCustomToolError(
f"Cannot export tool. Prompt(s): {', '.join(invalidated_prompts)} "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,7 @@ function PromptCard({
.then((res) => {
const data = res?.data?.output;
const outputValue = data[promptDetails?.prompt_key];
if (outputValue || outputValue === 0) {
updateDocCoverage(
promptDetails?.prompt_id,
profileManagerId,
docId
);
}
updateDocCoverage(promptDetails?.prompt_id, profileManagerId, docId);
handleDocOutputs(
docId,
promptDetails?.prompt_id,
Expand Down
16 changes: 0 additions & 16 deletions prompt-service/src/unstract/prompt_service/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,28 +204,12 @@ def prompt_processor() -> Any:
for output in outputs: # type:ignore
variable_names.append(output[PSKeys.NAME])
for output in outputs: # type:ignore
is_active = output[PSKeys.ACTIVE]
prompt_name = output[PSKeys.NAME]
promptx = output[PSKeys.PROMPT]
chunk_size = output[PSKeys.CHUNK_SIZE]
util = PromptServiceBaseTool(log_level=LogLevel.INFO, platform_key=platform_key)
index = Index(tool=util)

if is_active is False:
chandrasekharan-zipstack marked this conversation as resolved.
Show resolved Hide resolved
app.logger.info(f"[{tool_id}] Skipping inactive prompt: {prompt_name}")
_publish_log(
log_events_id,
{
"tool_id": tool_id,
"prompt_key": prompt_name,
"doc_name": doc_name,
},
LogLevel.INFO,
RunLevel.RUN,
"Skipping inactive prompt",
)
continue

app.logger.info(f"[{tool_id}] Executing prompt: {prompt_name}")
_publish_log(
log_events_id,
Expand Down
Loading