Spaces:
Sleeping
Sleeping
milwright
commited on
Commit
·
37a7438
1
Parent(s):
fed2199
fix ui issues: larger chat icons and proper book contextualization
Browse files- increased chat bubble icon size with responsive scaling
- fixed ai generating passage quotes instead of book facts
- improved contextualization prompt to generate literary insights
- src/aiService.js +2 -2
- src/clozeGameEngine.js +5 -4
- src/styles.css +27 -2
src/aiService.js
CHANGED
|
@@ -694,10 +694,10 @@ Return JSON: {"passage1": {"words": [${blanksPerPassage} words], "context": "one
|
|
| 694 |
model: this.primaryModel, // Use Gemma-3-12b for contextualization
|
| 695 |
messages: [{
|
| 696 |
role: 'system',
|
| 697 |
-
content: '
|
| 698 |
}, {
|
| 699 |
role: 'user',
|
| 700 |
-
content: `"${title}" by ${author}
|
| 701 |
}],
|
| 702 |
max_tokens: 150,
|
| 703 |
temperature: 0.5,
|
|
|
|
| 694 |
model: this.primaryModel, // Use Gemma-3-12b for contextualization
|
| 695 |
messages: [{
|
| 696 |
role: 'system',
|
| 697 |
+
content: 'You are a literary expert. Provide ONE interesting fact about this book or its author. Focus on: publication year, genre, historical context, author biography, literary significance, or themes. Do NOT quote or paraphrase passages from the book. Keep it under 20 words.'
|
| 698 |
}, {
|
| 699 |
role: 'user',
|
| 700 |
+
content: `Book: "${title}" by ${author}. Give me a brief fact about this work or author, not a quote from the text.`
|
| 701 |
}],
|
| 702 |
max_tokens: 150,
|
| 703 |
temperature: 0.5,
|
src/clozeGameEngine.js
CHANGED
|
@@ -84,7 +84,7 @@ class ClozeGame {
|
|
| 84 |
this.currentBook = book1;
|
| 85 |
this.originalText = this.passages[0];
|
| 86 |
await this.createClozeTextFromPreprocessed(0);
|
| 87 |
-
|
| 88 |
|
| 89 |
} catch (error) {
|
| 90 |
console.warn('Batch processing failed, falling back to sequential:', error);
|
|
@@ -840,7 +840,7 @@ class ClozeGame {
|
|
| 840 |
// Use preprocessed data if available
|
| 841 |
if (this.preprocessedData && this.preprocessedData.passage2) {
|
| 842 |
await this.createClozeTextFromPreprocessed(1);
|
| 843 |
-
|
| 844 |
} else {
|
| 845 |
// Fallback to sequential processing
|
| 846 |
await this.createClozeText();
|
|
@@ -984,9 +984,10 @@ class ClozeGame {
|
|
| 984 |
placeholder="${'_'.repeat(Math.max(3, blank.originalWord.length))}"
|
| 985 |
style="width: ${Math.max(50, blank.originalWord.length * 10)}px;">
|
| 986 |
<button id="${chatButtonId}"
|
| 987 |
-
class="chat-button text-blue-500 hover:text-blue-700
|
| 988 |
data-blank-index="${index}"
|
| 989 |
-
title="Ask question about this word"
|
|
|
|
| 990 |
💬
|
| 991 |
</button>
|
| 992 |
</span>`;
|
|
|
|
| 84 |
this.currentBook = book1;
|
| 85 |
this.originalText = this.passages[0];
|
| 86 |
await this.createClozeTextFromPreprocessed(0);
|
| 87 |
+
await this.generateContextualization();
|
| 88 |
|
| 89 |
} catch (error) {
|
| 90 |
console.warn('Batch processing failed, falling back to sequential:', error);
|
|
|
|
| 840 |
// Use preprocessed data if available
|
| 841 |
if (this.preprocessedData && this.preprocessedData.passage2) {
|
| 842 |
await this.createClozeTextFromPreprocessed(1);
|
| 843 |
+
await this.generateContextualization();
|
| 844 |
} else {
|
| 845 |
// Fallback to sequential processing
|
| 846 |
await this.createClozeText();
|
|
|
|
| 984 |
placeholder="${'_'.repeat(Math.max(3, blank.originalWord.length))}"
|
| 985 |
style="width: ${Math.max(50, blank.originalWord.length * 10)}px;">
|
| 986 |
<button id="${chatButtonId}"
|
| 987 |
+
class="chat-button text-blue-500 hover:text-blue-700"
|
| 988 |
data-blank-index="${index}"
|
| 989 |
+
title="Ask question about this word"
|
| 990 |
+
style="font-size: 1.5rem; line-height: 1;">
|
| 991 |
💬
|
| 992 |
</button>
|
| 993 |
</span>`;
|
src/styles.css
CHANGED
|
@@ -23,12 +23,37 @@
|
|
| 23 |
.chat-button {
|
| 24 |
transition: all 0.2s ease;
|
| 25 |
border-radius: 4px;
|
| 26 |
-
padding:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
}
|
| 28 |
|
| 29 |
.chat-button:hover {
|
| 30 |
background-color: rgba(59, 130, 246, 0.1);
|
| 31 |
-
transform: scale(1.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
|
| 34 |
/* Chat modal styling to match game font */
|
|
|
|
| 23 |
.chat-button {
|
| 24 |
transition: all 0.2s ease;
|
| 25 |
border-radius: 4px;
|
| 26 |
+
padding: 4px 6px;
|
| 27 |
+
font-size: 1.5rem;
|
| 28 |
+
vertical-align: middle;
|
| 29 |
+
display: inline-flex;
|
| 30 |
+
align-items: center;
|
| 31 |
+
justify-content: center;
|
| 32 |
+
min-width: 32px;
|
| 33 |
+
min-height: 32px;
|
| 34 |
}
|
| 35 |
|
| 36 |
.chat-button:hover {
|
| 37 |
background-color: rgba(59, 130, 246, 0.1);
|
| 38 |
+
transform: scale(1.15);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Responsive sizing for mobile */
|
| 42 |
+
@media (max-width: 640px) {
|
| 43 |
+
.chat-button {
|
| 44 |
+
font-size: 1.25rem;
|
| 45 |
+
min-width: 28px;
|
| 46 |
+
min-height: 28px;
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/* Larger screens get bigger icons */
|
| 51 |
+
@media (min-width: 1024px) {
|
| 52 |
+
.chat-button {
|
| 53 |
+
font-size: 1.75rem;
|
| 54 |
+
min-width: 36px;
|
| 55 |
+
min-height: 36px;
|
| 56 |
+
}
|
| 57 |
}
|
| 58 |
|
| 59 |
/* Chat modal styling to match game font */
|