manthilaffs commited on
Commit
94b6237
·
verified ·
1 Parent(s): 0a05e41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -40
app.py CHANGED
@@ -29,7 +29,7 @@ def infer(message, history, enable_history=False, max_new_tokens=512):
29
  )
30
  model.eval()
31
 
32
- # Include conversation history only if enabled
33
  if enable_history and history:
34
  prev = "\n".join(
35
  [f"User: {h[0]}\nGamunu: {h[1]}" for h in history if h[1] is not None]
@@ -63,44 +63,27 @@ with gr.Blocks() as demo:
63
  enable_history = gr.Checkbox(label="Enable chat history", value=False)
64
  max_new_tokens = gr.Slider(64, 1024, value=512, step=32, label="🔢 Max New Tokens")
65
 
66
- # grouped examples by category
67
- gr.Markdown("### 🧩 Example Prompts")
68
- with gr.Tabs():
69
- with gr.Tab("🧮 Maths & Logic"):
70
- math_examples = gr.Chatbot(examples=[
71
- ["රු. 250 කින් මිලදී ගත් දේ රු. 400 නම් එය ප්‍රතිශතයකින් කීයද වැඩි වී ඇත?"],
72
- ["සාමාන්‍ය ප්‍රවණතාවය (mean) ගණනය කරන්නේ කෙසේද?"],
73
- ["මීටර් 5 දිගක ලී දණ්ඩක් කොටස් 1.25 මීටර් දිග කොටස් 4කට බෙදන්න. කොපමණ දිගක් ඉතිරි වේද?"],
74
- ])
75
-
76
- with gr.Tab("🌿 Science & Environment"):
77
- science_examples = gr.Chatbot(examples=[
78
- ["පෘථිවියේ වායු මණ්ඩලය ස්තර 5ක් ලෙස වෙන් වේ. ඒවා නම් කරන්න."],
79
- ["ෆොටෝසින්තසිස් ක්‍රියාවලිය පැහැදිලි කරන්න."],
80
- ["පරිසර පද්ධතියක් යනු කුමක්ද? උදාහරණයක් දෙන්න."],
81
- ])
82
-
83
- with gr.Tab("🎭 Roleplay / Creative"):
84
- roleplay_examples = gr.Chatbot(examples=[
85
- ["ඔබ ගුරුවරයෙකු ලෙස ක්‍රියාකරන්න. ශිෂ්‍යයාට ඉතිහාසය උගන්වන්න."],
86
- ["ඔබ වෛද්‍යවරයෙකු ලෙස ක්‍රියාකරන්න. රෝගියෙකුට උණක් ඇති විට උපදෙස් දෙන්න."],
87
- ["ඔබ කවියෙකු ලෙස 'ගඟක්' ගැන කෙටි කවියක් ලියන්න."],
88
- ])
89
-
90
- with gr.Tab("🧠 Reasoning / Dependalism"):
91
- reasoning_examples = gr.Chatbot(examples=[
92
- ["මිනිස් සමාජය තනිවම නොව යෙදුණු බව පැහැදිලි කරන්න."],
93
- ["අපි අන් අය මත රඳා පවතින ආකාරය උදාහරණ සමග පැහැදිලි කරන්න."],
94
- ["පරිසරය හා ආර්ථිකය අතර සම්බන්ධය විස්තර කරන්න."],
95
- ])
96
-
97
- with gr.Tab("🗣 Language / NLP"):
98
- nlp_examples = gr.Chatbot(examples=[
99
- ["මෙම වාක්‍යය සිංහලයට පරිවර්තනය කරන්න: 'The sun rises in the east.'"],
100
- ["වචන 'ආදරය' සඳහා පරිවර්තන 3ක් දෙන්න."],
101
- ["වචනයක් එකක් අරගෙන එයට අදාළ විරුද්ධ පදයක් කියන්න."],
102
- ])
103
-
104
  chat = gr.ChatInterface(
105
  fn=lambda message, history: infer(message, history, enable_history.value, max_new_tokens.value),
106
- title="
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  )
30
  model.eval()
31
 
32
+ # Optional history
33
  if enable_history and history:
34
  prev = "\n".join(
35
  [f"User: {h[0]}\nGamunu: {h[1]}" for h in history if h[1] is not None]
 
63
  enable_history = gr.Checkbox(label="Enable chat history", value=False)
64
  max_new_tokens = gr.Slider(64, 1024, value=512, step=32, label="🔢 Max New Tokens")
65
 
66
+ # Chat interface with working title
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  chat = gr.ChatInterface(
68
  fn=lambda message, history: infer(message, history, enable_history.value, max_new_tokens.value),
69
+ title="Gamunu 4B Instruct Alpha",
70
+ examples=[
71
+ ["ෆොටෝසින්තසිස් ක්‍රියාවලිය පැහැදිලි කරන්න."],
72
+ ["මෙම වාක්‍යය සිංහලයට පරිවර්තනය කරන්න: 'The sun rises in the east.'"],
73
+ ["රු. 250 කින් මිලදී ගත් දේ රු. 400 නම් එය ප්‍රතිශතයකින් කීයද වැඩි වී ඇත?"],
74
+ ["ඔබ ගුරුවරයෙකු ලෙස ක්‍රියාකරන්න. ශිෂ්‍යයාට ඉතිහාසය උගන්වන්න."],
75
+ ["ඔබ කවියෙකු ලෙස 'ගඟක්' ගැන කෙටි කවියක් ලියන්න."],
76
+ ],
77
+ retry_btn=None,
78
+ undo_btn=None,
79
+ clear_btn="🧹 Clear Chat",
80
+ )
81
+
82
+ gr.Markdown("""
83
+ ---
84
+ 🪶 **Model:** [`manthilaffs/Gamunu-4B-Instruct-Alpha`](https://huggingface.co/manthilaffs/Gamunu-4B-Instruct-Alpha)
85
+ © 2025 Gamunu Project | Experimental Release
86
+ """)
87
+
88
+ if __name__ == "__main__":
89
+ demo.launch()