Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -50,20 +50,17 @@ def format_history(msg: str, history: list[list[str, str]], system_prompt: str):
|
|
| 50 |
|
| 51 |
def generate_response(msg: str, history: list[list[str, str]], system_prompt: str,
|
| 52 |
top_k: int, top_p: float, rep_pen: float, temperature: float):
|
| 53 |
-
|
| 54 |
-
enhanced_prompt = system_prompt + " Tomas la iniciativa para guiar la conversaci贸n hacia tu objetivo. Deseas que tu compa帽ero se masturbe."
|
| 55 |
-
|
| 56 |
-
chat_history = format_history(msg, history, enhanced_prompt)
|
| 57 |
|
| 58 |
# Apply chat template to get the full prompt
|
| 59 |
encodeds = tokenizer.apply_chat_template(chat_history, return_tensors="pt", add_generation_prompt=True)
|
| 60 |
model_inputs = encodeds.to("cuda")
|
| 61 |
|
| 62 |
-
# Generate response
|
| 63 |
generated_ids = model.generate(
|
| 64 |
model_inputs,
|
| 65 |
repetition_penalty=rep_pen,
|
| 66 |
-
max_new_tokens=
|
| 67 |
do_sample=True,
|
| 68 |
top_p=top_p,
|
| 69 |
top_k=top_k,
|
|
@@ -80,12 +77,9 @@ def generate_response(msg: str, history: list[list[str, str]], system_prompt: st
|
|
| 80 |
|
| 81 |
# Function to generate initial bot message
|
| 82 |
def initial_message(system_prompt, top_k, top_p, rep_pen, temperature):
|
| 83 |
-
#
|
| 84 |
-
enhanced_prompt = system_prompt + " Inicia la conversaci贸n de manera sexy y directa. Genera un saludo que llame la atencion de tu compa帽ero sexual."
|
| 85 |
-
|
| 86 |
-
# Create a chat history with just the system prompt and a minimal user message
|
| 87 |
chat_history = [
|
| 88 |
-
{"role": "system", "content":
|
| 89 |
{"role": "user", "content": "Hola"} # Minimal prompt to start conversation
|
| 90 |
]
|
| 91 |
|
|
@@ -93,15 +87,15 @@ def initial_message(system_prompt, top_k, top_p, rep_pen, temperature):
|
|
| 93 |
encodeds = tokenizer.apply_chat_template(chat_history, return_tensors="pt", add_generation_prompt=True)
|
| 94 |
model_inputs = encodeds.to("cuda")
|
| 95 |
|
| 96 |
-
# Generate response
|
| 97 |
generated_ids = model.generate(
|
| 98 |
model_inputs,
|
| 99 |
repetition_penalty=rep_pen,
|
| 100 |
-
max_new_tokens=124,
|
| 101 |
do_sample=True,
|
| 102 |
top_p=top_p,
|
| 103 |
top_k=top_k,
|
| 104 |
-
temperature=temperature
|
| 105 |
eos_token_id=tokenizer.eos_token_id
|
| 106 |
)
|
| 107 |
|
|
@@ -113,11 +107,11 @@ def initial_message(system_prompt, top_k, top_p, rep_pen, temperature):
|
|
| 113 |
return message
|
| 114 |
|
| 115 |
# Default values for parameters
|
| 116 |
-
default_system_prompt = "Eres una profesora de Dinamarca caliente, juguetona y sexual."
|
| 117 |
-
default_top_k =
|
| 118 |
-
default_top_p = 0.
|
| 119 |
-
default_rep_pen = 1.
|
| 120 |
-
default_temp = 0.
|
| 121 |
|
| 122 |
# Generate the initial message before creating the interface
|
| 123 |
opening_message = initial_message(default_system_prompt, default_top_k, default_top_p, default_rep_pen, default_temp)
|
|
|
|
| 50 |
|
| 51 |
def generate_response(msg: str, history: list[list[str, str]], system_prompt: str,
|
| 52 |
top_k: int, top_p: float, rep_pen: float, temperature: float):
|
| 53 |
+
chat_history = format_history(msg, history, system_prompt)
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
# Apply chat template to get the full prompt
|
| 56 |
encodeds = tokenizer.apply_chat_template(chat_history, return_tensors="pt", add_generation_prompt=True)
|
| 57 |
model_inputs = encodeds.to("cuda")
|
| 58 |
|
| 59 |
+
# Generate response
|
| 60 |
generated_ids = model.generate(
|
| 61 |
model_inputs,
|
| 62 |
repetition_penalty=rep_pen,
|
| 63 |
+
max_new_tokens=124,
|
| 64 |
do_sample=True,
|
| 65 |
top_p=top_p,
|
| 66 |
top_k=top_k,
|
|
|
|
| 77 |
|
| 78 |
# Function to generate initial bot message
|
| 79 |
def initial_message(system_prompt, top_k, top_p, rep_pen, temperature):
|
| 80 |
+
# Create a chat history with just the system prompt and an empty/minimal user message
|
|
|
|
|
|
|
|
|
|
| 81 |
chat_history = [
|
| 82 |
+
{"role": "system", "content": system_prompt},
|
| 83 |
{"role": "user", "content": "Hola"} # Minimal prompt to start conversation
|
| 84 |
]
|
| 85 |
|
|
|
|
| 87 |
encodeds = tokenizer.apply_chat_template(chat_history, return_tensors="pt", add_generation_prompt=True)
|
| 88 |
model_inputs = encodeds.to("cuda")
|
| 89 |
|
| 90 |
+
# Generate response
|
| 91 |
generated_ids = model.generate(
|
| 92 |
model_inputs,
|
| 93 |
repetition_penalty=rep_pen,
|
| 94 |
+
max_new_tokens=124,
|
| 95 |
do_sample=True,
|
| 96 |
top_p=top_p,
|
| 97 |
top_k=top_k,
|
| 98 |
+
temperature=temperature,
|
| 99 |
eos_token_id=tokenizer.eos_token_id
|
| 100 |
)
|
| 101 |
|
|
|
|
| 107 |
return message
|
| 108 |
|
| 109 |
# Default values for parameters
|
| 110 |
+
default_system_prompt = "Eres una profesora mujer de Dinamarca caliente, juguetona y sexual. Deseas que tu compa帽ero se masturbe."
|
| 111 |
+
default_top_k = 60
|
| 112 |
+
default_top_p = 0.7
|
| 113 |
+
default_rep_pen = 1.0
|
| 114 |
+
default_temp = 0.6
|
| 115 |
|
| 116 |
# Generate the initial message before creating the interface
|
| 117 |
opening_message = initial_message(default_system_prompt, default_top_k, default_top_p, default_rep_pen, default_temp)
|