Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,16 +33,33 @@ max_new_tokens2=1048
|
|
33 |
top_p=0.95
|
34 |
repetition_penalty=1.0,
|
35 |
|
36 |
-
def compress_history(
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
)
|
42 |
-
history
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
|
|
46 |
|
47 |
|
48 |
def question_generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,):
|
|
|
33 |
top_p=0.95
|
34 |
repetition_penalty=1.0,
|
35 |
|
36 |
+
def compress_history(formatted_prompt):
|
37 |
+
seed = random.randint(1,1111111111111111)
|
38 |
+
agent=prompts.COMPRESS_HISTORY_PROMPT
|
39 |
+
system_prompt=agent
|
40 |
+
temperature = 0.9
|
41 |
+
if temperature < 1e-2:
|
42 |
+
temperature = 1e-2
|
43 |
+
|
44 |
+
generate_kwargs = dict(
|
45 |
+
temperature=temperature,
|
46 |
+
max_new_tokens=512,
|
47 |
+
top_p=0.95,
|
48 |
+
repetition_penalty=1.0,
|
49 |
+
do_sample=True,
|
50 |
+
seed=seed,
|
51 |
)
|
52 |
+
#history.append((prompt,""))
|
53 |
+
#formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
54 |
+
formatted_prompt = formatted_prompt
|
55 |
+
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
56 |
+
output = ""
|
57 |
+
|
58 |
+
for response in stream:
|
59 |
+
output += response.token.text
|
60 |
+
#history.append((output,history))
|
61 |
|
62 |
+
return output
|
63 |
|
64 |
|
65 |
def question_generate(prompt, history, agent_name=agents[0], sys_prompt="", temperature=0.9, max_new_tokens=256, top_p=0.95, repetition_penalty=1.0,):
|