Skip to content

Commit b589eee

Browse files
addressed pr comments
1 parent 9000cd0 commit b589eee

File tree

4 files changed

+30
-27
lines changed

4 files changed

+30
-27
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Generated by Django 4.2.1 on 2024-12-20 06:35
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
("prompt_studio_v2", "0004_alter_toolstudioprompt_required"),
10+
]
11+
12+
operations = [
13+
migrations.AlterField(
14+
model_name="toolstudioprompt",
15+
name="required",
16+
field=models.CharField(
17+
blank=True,
18+
choices=[("all", "All values required"), ("any", "Any value required")],
19+
db_comment="Field to store weather the values all values or any values required. This is used for HQR, based on the value approve or finish review",
20+
default=None,
21+
null=True,
22+
),
23+
),
24+
]

backend/prompt_studio/prompt_studio_v2/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,13 @@ class RequiredType(models.TextChoices):
9393
unique=False,
9494
)
9595
required = models.CharField(
96-
max_length=3,
9796
choices=RequiredType.choices,
9897
null=True, # Allows the field to store NULL in the database
9998
blank=True, # Allows the field to be optional in forms
10099
default=None, # Sets the default value to None
100+
db_comment="Field to store weather the values all values or any \
101+
values required. This is used for HQR, based on the value approve or finish \
102+
review",
101103
)
102104
is_assert = models.BooleanField(default=False)
103105
active = models.BooleanField(default=True, null=False, blank=False)

prompt-service/src/unstract/prompt_service/helper.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -396,24 +396,3 @@ def extract_table(
396396
except table_extractor["exception_cls"] as e:
397397
msg = f"Couldn't extract table. {e}"
398398
raise APIError(message=msg)
399-
400-
401-
def add_required_field(
402-
required_fields: dict[str, str], key: str, required: str
403-
) -> dict[str, str]:
404-
"""
405-
Add or update a required field in the required_fields dictionary.
406-
407-
Args:
408-
required_fields (Dict[str, str]): The dictionary
409-
containing existing required fields,
410-
where keys are field names and values are boolean flags.
411-
key (str): The field key to add or update in the dictionary.
412-
required (str): A indicating whether the
413-
all/any values in field is required.
414-
415-
Returns:
416-
Dict[str, str]: The updated dictionary of required fields.
417-
"""
418-
required_fields[key] = required
419-
return required_fields

prompt-service/src/unstract/prompt_service/main.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from unstract.prompt_service.constants import RunLevel
1212
from unstract.prompt_service.exceptions import APIError, ErrorResponse, NoPayloadError
1313
from unstract.prompt_service.helper import (
14-
add_required_field,
1514
construct_and_run_prompt,
1615
extract_table,
1716
extract_variable,
@@ -125,11 +124,10 @@ def prompt_processor() -> Any:
125124
# TODO: Rename "output" to "prompt"
126125
for output in prompts: # type:ignore
127126
variable_names.append(output[PSKeys.NAME])
128-
metadata[PSKeys.REQUIRED_FIELDS] = add_required_field(
129-
metadata[PSKeys.REQUIRED_FIELDS],
130-
output[PSKeys.NAME],
131-
output.get(PSKeys.REQUIRED, None),
127+
metadata[PSKeys.REQUIRED_FIELDS][output[PSKeys.NAME]] = output.get(
128+
PSKeys.REQUIRED, None
132129
)
130+
133131
for output in prompts: # type:ignore
134132
prompt_name = output[PSKeys.NAME]
135133
prompt_text = output[PSKeys.PROMPT]

0 commit comments

Comments
 (0)