Spaces:
Running
Running
Update index.js
Browse files
index.js
CHANGED
|
@@ -153,18 +153,6 @@ class StreamingChatbot {
|
|
| 153 |
streamingIndicator.style.marginLeft = '4px';
|
| 154 |
messageContent.appendChild(streamingIndicator);
|
| 155 |
|
| 156 |
-
// Create a simple prompt from the last few messages
|
| 157 |
-
const recentMessages = this.messages.slice(-6); // Keep last 6 messages for context
|
| 158 |
-
let prompt = "";
|
| 159 |
-
for (const msg of recentMessages) {
|
| 160 |
-
if (msg.role === "user") {
|
| 161 |
-
prompt += `Human: ${msg.content}\n`;
|
| 162 |
-
} else {
|
| 163 |
-
prompt += `Assistant: ${msg.content}\n`;
|
| 164 |
-
}
|
| 165 |
-
}
|
| 166 |
-
prompt += "Assistant:";
|
| 167 |
-
|
| 168 |
// Create enhanced TextStreamer with proper callback handling
|
| 169 |
this.currentStreamer = new TextStreamer(this.generator.tokenizer, {
|
| 170 |
skip_prompt: true,
|
|
@@ -180,14 +168,11 @@ class StreamingChatbot {
|
|
| 180 |
}
|
| 181 |
});
|
| 182 |
|
| 183 |
-
//
|
| 184 |
-
const output = await this.generator(
|
| 185 |
-
max_new_tokens:
|
| 186 |
-
do_sample:
|
| 187 |
-
temperature: 0.7,
|
| 188 |
-
top_p: 0.9,
|
| 189 |
streamer: this.currentStreamer,
|
| 190 |
-
return_full_text: false
|
| 191 |
});
|
| 192 |
|
| 193 |
// Clean up streaming indicator if still present
|
|
|
|
| 153 |
streamingIndicator.style.marginLeft = '4px';
|
| 154 |
messageContent.appendChild(streamingIndicator);
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
// Create enhanced TextStreamer with proper callback handling
|
| 157 |
this.currentStreamer = new TextStreamer(this.generator.tokenizer, {
|
| 158 |
skip_prompt: true,
|
|
|
|
| 168 |
}
|
| 169 |
});
|
| 170 |
|
| 171 |
+
// Use the original working format - messages array with streamer
|
| 172 |
+
const output = await this.generator(this.messages, {
|
| 173 |
+
max_new_tokens: 500,
|
| 174 |
+
do_sample: false,
|
|
|
|
|
|
|
| 175 |
streamer: this.currentStreamer,
|
|
|
|
| 176 |
});
|
| 177 |
|
| 178 |
// Clean up streaming indicator if still present
|