hruday96 commited on
Commit
b92d835
Β·
verified Β·
1 Parent(s): a5bb0e9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -9
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
- {"role": "system", "content": f"You are a prompt engineering assistant. Your job is to improve and enhance the given prompt using the '{selected_technique}' technique. Do not answer the prompt, just rewrite it in an improved way."},
 
 
 
 
 
 
 
 
49
  {"role": "user", "content": user_prompt}
50
  ],
51
- temperature=0.7,
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=150)
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)}")