Skip to content

Commit

Permalink
Slight code formatting improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSkala committed Feb 11, 2024
1 parent 5d8e376 commit 3100525
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions prompterator/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ def show_suggestions():
"""

max_tokens = 4000
model_name = "gpt-4"
model_name = "gpt-4" # Specific only for this one feature

if "n_checked" not in st.session_state:
st.session_state.n_checked = 0
Expand All @@ -612,20 +612,31 @@ def show_suggestions():
# there is at least one Bad label
if (st.session_state.n_checked / len(st.session_state.df) >= 0.8) and (c.LABEL_BAD in st.session_state.df[c.LABEL_COL].values):
content = st.session_state.df.to_dict(orient="records")
prompt = st.session_state.system_prompt

content_with_label_good = [f"Original: {text[c.TEXT_ORIG_COL]}\nGenerated: {text[c.TEXT_GENERATED_COL]}\nLabel: {text[c.LABEL_COL]}" for text in content if text[c.LABEL_COL] == c.LABEL_GOOD]
content_with_label_bad = [f"Original: {text[c.TEXT_ORIG_COL]}\nGenerated: {text[c.TEXT_GENERATED_COL]}\nLabel: {text[c.LABEL_COL]}" for text in content if text[c.LABEL_COL] == c.LABEL_BAD]
content_with_label_good = [
(f"Original: {text[c.TEXT_ORIG_COL]}\n"
f"Generated: {text[c.TEXT_GENERATED_COL]}\n"
f"Label: {text[c.LABEL_COL]}")
for text in content if text[c.LABEL_COL] == c.LABEL_GOOD
]

prompt = st.session_state.system_prompt
content_with_label_bad = [
(f"Original: {text[c.TEXT_ORIG_COL]}\n"
f"Generated: {text[c.TEXT_GENERATED_COL]}\n"
f"Label: {text[c.LABEL_COL]}")
for text in content if text[c.LABEL_COL] == c.LABEL_BAD
]

mixed_content = u.mix_content(content_with_label_bad, content_with_label_good, max_tokens)
format_mixed_content = u.format_mixed_content(mixed_content)

system_prompt = (f"Here is a dataset of texts, responses, and human labels (first the "
f"ones labeled as Bad, then the ones lab"
f"eled as Good): \n\n{format_mixed_content}\n\nHere is the Prompt that "
f"ones labeled as Bad, then the ones labeled as Good):"
f"\n\n{format_mixed_content}\n\nHere is the Prompt that "
f"led to the generated responses: '{prompt}'\n\nPlease suggest "
f"improvements to the Prompt above.")

user_prompt = ("Follow the system prompt and only output suggestions on how to improve "
"the prompt.")

Expand Down

0 comments on commit 3100525

Please sign in to comment.