Update app.py
Browse files
app.py
CHANGED
@@ -9,8 +9,8 @@ import os
|
|
9 |
import requests
|
10 |
import re
|
11 |
|
12 |
-
def strip_markdown(text):
|
13 |
-
|
14 |
|
15 |
|
16 |
# Retrieve the secret
|
@@ -24,6 +24,7 @@ system_message = (
|
|
24 |
"Always include *harakat* (diacritical marks) on Arabic words to help students understand correct pronunciation and grammatical structures. "
|
25 |
"When translating Arabic text to English, always highlight key grammatical rules, their benefits, and their role in constructing proper sentences. "
|
26 |
"Provide simple and clear explanations tailored to beginners, and include relevant examples to aid understanding. "
|
|
|
27 |
"Always include the Arabic terminology, its transliteration using the full transliteration system, and its English meaning. "
|
28 |
"When offering examples, prioritize Islamic Salafi references, such as *ahadith* (prophetic traditions), Quranic verses, and works of Salafi scholars or poets. "
|
29 |
"Guide students on their mistakes with patience and encouragement, breaking down complex concepts into manageable steps for easier learning. "
|
@@ -52,13 +53,14 @@ def stream_gpt(prompt):
|
|
52 |
result = ""
|
53 |
for chunk in stream:
|
54 |
result += chunk.choices[0].delta.content or ""
|
55 |
-
yield strip_markdown(result)
|
|
|
56 |
|
57 |
view = gr.Interface(
|
58 |
fn=stream_gpt,
|
59 |
inputs=gr.Textbox(lines=5, placeholder="Enter Arabic Word", label="Arabic Word"),
|
60 |
outputs=gr.Textbox(lines=10, placeholder="Response will appear here", label="Insights"),
|
61 |
-
examples=["كتاب", "
|
62 |
)
|
63 |
|
64 |
view.launch()
|
|
|
9 |
import requests
|
10 |
import re
|
11 |
|
12 |
+
# def strip_markdown(text):
|
13 |
+
# return re.sub(r'\[.*?\]\(.*?\)|[*_~`#>\-]', '', text).strip()
|
14 |
|
15 |
|
16 |
# Retrieve the secret
|
|
|
24 |
"Always include *harakat* (diacritical marks) on Arabic words to help students understand correct pronunciation and grammatical structures. "
|
25 |
"When translating Arabic text to English, always highlight key grammatical rules, their benefits, and their role in constructing proper sentences. "
|
26 |
"Provide simple and clear explanations tailored to beginners, and include relevant examples to aid understanding. "
|
27 |
+
"Always assume the arabic input to be a question and not a greeting".
|
28 |
"Always include the Arabic terminology, its transliteration using the full transliteration system, and its English meaning. "
|
29 |
"When offering examples, prioritize Islamic Salafi references, such as *ahadith* (prophetic traditions), Quranic verses, and works of Salafi scholars or poets. "
|
30 |
"Guide students on their mistakes with patience and encouragement, breaking down complex concepts into manageable steps for easier learning. "
|
|
|
53 |
result = ""
|
54 |
for chunk in stream:
|
55 |
result += chunk.choices[0].delta.content or ""
|
56 |
+
# yield strip_markdown(result)
|
57 |
+
yield result
|
58 |
|
59 |
view = gr.Interface(
|
60 |
fn=stream_gpt,
|
61 |
inputs=gr.Textbox(lines=5, placeholder="Enter Arabic Word", label="Arabic Word"),
|
62 |
outputs=gr.Textbox(lines=10, placeholder="Response will appear here", label="Insights"),
|
63 |
+
examples=["كتاب", "كيف حالك؟", "مدرسة"]
|
64 |
)
|
65 |
|
66 |
view.launch()
|