rahul7star commited on
Commit
fd97af7
·
verified ·
1 Parent(s): 401afad

Update app_low.py

Browse files
Files changed (1) hide show
  1. app_low.py +6 -7
app_low.py CHANGED
@@ -25,22 +25,21 @@ pipe = pipeline(
25
  # 2️⃣ Define the generation function
26
  # ============================================================
27
  def enhance_prompt(user_prompt, temperature, max_tokens, chat_history):
28
- """Enhance user prompt and maintain chat history."""
29
- if not user_prompt.strip():
30
- return chat_history + [["", "⚠️ Please enter a prompt."]]
31
 
32
  full_prompt = f"Enhance and expand the following prompt with more details and context: {user_prompt}"
33
 
34
- # Generate output
35
  output = pipe(
36
  full_prompt,
37
  max_new_tokens=int(max_tokens),
38
  temperature=float(temperature),
39
  do_sample=True,
40
- )
 
 
 
 
41
 
42
- result = output[0]['generated_text'].strip()
43
- chat_history = chat_history + [[user_prompt, result]]
44
  return chat_history
45
 
46
  # ============================================================
 
25
  # 2️⃣ Define the generation function
26
  # ============================================================
27
  def enhance_prompt(user_prompt, temperature, max_tokens, chat_history):
28
+ chat_history = chat_history or []
 
 
29
 
30
  full_prompt = f"Enhance and expand the following prompt with more details and context: {user_prompt}"
31
 
 
32
  output = pipe(
33
  full_prompt,
34
  max_new_tokens=int(max_tokens),
35
  temperature=float(temperature),
36
  do_sample=True,
37
+ )[0]['generated_text'].strip()
38
+
39
+ # Convert to Gradio messages format
40
+ chat_history.append({"role": "user", "content": user_prompt})
41
+ chat_history.append({"role": "assistant", "content": output})
42
 
 
 
43
  return chat_history
44
 
45
  # ============================================================