Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -45,20 +45,25 @@ if st.button("Enhance Prompt"):
|
|
45 |
completion = client.chat.completions.create(
|
46 |
model="gpt-4o",
|
47 |
messages=[
|
48 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
49 |
{"role": "user", "content": user_prompt}
|
50 |
],
|
51 |
-
temperature=0.
|
52 |
-
max_tokens=500
|
53 |
)
|
54 |
-
enhanced_prompt = completion.choices[0].message.content
|
55 |
|
56 |
-
# π Display Enhanced Prompt
|
57 |
st.subheader("πΉ Enhanced Prompt:")
|
58 |
-
st.text_area(" ", value=enhanced_prompt, height=
|
59 |
-
|
60 |
-
# π Copy Button (Updated with `st.query_params`)
|
61 |
-
st.query_params.enhanced_prompt = enhanced_prompt
|
62 |
|
63 |
except Exception as e:
|
64 |
st.error(f"β Error: {str(e)}")
|
|
|
45 |
completion = client.chat.completions.create(
|
46 |
model="gpt-4o",
|
47 |
messages=[
|
48 |
+
{
|
49 |
+
"role": "system",
|
50 |
+
"content": f"""
|
51 |
+
Your task is to rewrite and improve the given prompt using the '{selected_technique}' technique.
|
52 |
+
**DO NOT ANSWER** the prompt.
|
53 |
+
**DO NOT GENERATE ADDITIONAL INFORMATION.**
|
54 |
+
**ONLY return the improved prompt, keeping the original intent intact.**
|
55 |
+
"""
|
56 |
+
},
|
57 |
{"role": "user", "content": user_prompt}
|
58 |
],
|
59 |
+
temperature=0.3, # Low randomness
|
60 |
+
max_tokens=min(len(user_prompt) * 1.5, 500) # Limit expansion
|
61 |
)
|
62 |
+
enhanced_prompt = completion.choices[0].message.content.strip()
|
63 |
|
64 |
+
# π Display Enhanced Prompt in a Larger Text Box
|
65 |
st.subheader("πΉ Enhanced Prompt:")
|
66 |
+
st.text_area(" ", value=enhanced_prompt, height=250) # Bigger text box
|
|
|
|
|
|
|
67 |
|
68 |
except Exception as e:
|
69 |
st.error(f"β Error: {str(e)}")
|