complete history
Browse files
app.py
CHANGED
@@ -21,16 +21,14 @@ def generate_prompt(instruction, input=None, history=None):
|
|
21 |
for pair in history:
|
22 |
if len(pair[0]) > 0 and len(pair[1]) > 0:
|
23 |
history_str += f"User: {pair[0]}\n\nAssistant: {pair[1]}\n\n"
|
24 |
-
|
25 |
-
instruction =
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
)
|
33 |
-
if not has_history:
|
34 |
input = (
|
35 |
input.strip()
|
36 |
.replace("\r\n", "\n")
|
@@ -93,9 +91,10 @@ examples = [
|
|
93 |
|
94 |
|
95 |
def respond(history=None):
|
96 |
-
global token_count_chat, temperature_chat, top_p_chat, presence_penalty_chat, count_penalty_chat
|
97 |
|
98 |
# get the lastest user message and the additional parameters
|
|
|
99 |
token_count = token_count_chat.value
|
100 |
|
101 |
temperature = temperature_chat.value
|
@@ -106,7 +105,7 @@ def respond(history=None):
|
|
106 |
history[-1][1] = ""
|
107 |
|
108 |
for character in generator(
|
109 |
-
|
110 |
None,
|
111 |
token_count,
|
112 |
temperature,
|
@@ -130,7 +129,7 @@ def generator(
|
|
130 |
history=None
|
131 |
):
|
132 |
args = PIPELINE_ARGS(
|
133 |
-
temperature=max(0
|
134 |
top_p=float(top_p),
|
135 |
alpha_frequency=countPenalty,
|
136 |
alpha_presence=presencePenalty,
|
|
|
21 |
for pair in history:
|
22 |
if len(pair[0]) > 0 and len(pair[1]) > 0:
|
23 |
history_str += f"User: {pair[0]}\n\nAssistant: {pair[1]}\n\n"
|
24 |
+
if instruction:
|
25 |
+
instruction = (
|
26 |
+
instruction.strip()
|
27 |
+
.replace("\r\n", "\n")
|
28 |
+
.replace("\n\n", "\n")
|
29 |
+
.replace("\n\n", "\n")
|
30 |
+
)
|
31 |
+
if input:
|
|
|
|
|
32 |
input = (
|
33 |
input.strip()
|
34 |
.replace("\r\n", "\n")
|
|
|
91 |
|
92 |
|
93 |
def respond(history=None):
|
94 |
+
global msg, token_count_chat, temperature_chat, top_p_chat, presence_penalty_chat, count_penalty_chat
|
95 |
|
96 |
# get the lastest user message and the additional parameters
|
97 |
+
instruction = msg.value
|
98 |
token_count = token_count_chat.value
|
99 |
|
100 |
temperature = temperature_chat.value
|
|
|
105 |
history[-1][1] = ""
|
106 |
|
107 |
for character in generator(
|
108 |
+
instruction,
|
109 |
None,
|
110 |
token_count,
|
111 |
temperature,
|
|
|
129 |
history=None
|
130 |
):
|
131 |
args = PIPELINE_ARGS(
|
132 |
+
temperature=max(2.0, float(temperature)),
|
133 |
top_p=float(top_p),
|
134 |
alpha_frequency=countPenalty,
|
135 |
alpha_presence=presencePenalty,
|