Commit
·
68cc827
1
Parent(s):
3c730fe
Update app.py
Browse files
app.py
CHANGED
|
@@ -215,7 +215,14 @@ def update_explanation(choice):
|
|
| 215 |
|
| 216 |
# Adjusted predict function to handle None temperature
|
| 217 |
def predict(user_message, selected_style, temperature=0.7):
|
| 218 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
|
| 220 |
# Define the Gradio interface using Blocks
|
| 221 |
with gr.Blocks() as demo:
|
|
|
|
| 215 |
|
| 216 |
# Adjusted predict function to handle None temperature
|
| 217 |
def predict(user_message, selected_style, temperature=0.7):
|
| 218 |
+
system_prompt = styles_prompts_dict[selected_style]
|
| 219 |
+
sampling_params = SamplingParams(temperature=temperature, top_p=.95, max_tokens=500, presence_penalty = 2)
|
| 220 |
+
detailed_prompt = "<|im_start|>system\n" + system_prompt + "<|im_end|>\n<|im_start|>user"""
|
| 221 |
+
detailed_prompt = detailed_prompt + "\n" + user_message + "<|im_end|>\n<|im_start|>assistant\n"
|
| 222 |
+
prompts = [detailed_prompt]
|
| 223 |
+
outputs = llm.generate(prompts, sampling_params, use_tqdm = False)
|
| 224 |
+
generated_text = outputs[0].outputs[0].text
|
| 225 |
+
return generated_text
|
| 226 |
|
| 227 |
# Define the Gradio interface using Blocks
|
| 228 |
with gr.Blocks() as demo:
|