Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,15 @@
|
|
1 |
import urllib.parse
|
2 |
import requests
|
3 |
import gradio as gr
|
4 |
-
from transformers import pipeline
|
5 |
|
6 |
# 🟢 API Templates للحصول على بيانات ويكيبيديا
|
7 |
SEARCH_TEMPLATE = "https://ar.wikipedia.org/w/api.php?action=opensearch&search=%s&limit=1&namespace=0&format=json"
|
8 |
CONTENT_TEMPLATE = "https://ar.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=%s"
|
9 |
|
10 |
-
# 🔥
|
11 |
-
|
|
|
12 |
|
13 |
def search_wikipedia(query):
|
14 |
""" البحث في ويكيبيديا العربية وإرجاع ملخص من المقال الأول. """
|
@@ -68,3 +69,4 @@ with gr.Blocks() as demo:
|
|
68 |
|
69 |
if __name__ == "__main__":
|
70 |
demo.launch()
|
|
|
|
1 |
import urllib.parse
|
2 |
import requests
|
3 |
import gradio as gr
|
4 |
+
from transformers import pipeline, MBartTokenizer
|
5 |
|
6 |
# 🟢 API Templates للحصول على بيانات ويكيبيديا
|
7 |
SEARCH_TEMPLATE = "https://ar.wikipedia.org/w/api.php?action=opensearch&search=%s&limit=1&namespace=0&format=json"
|
8 |
CONTENT_TEMPLATE = "https://ar.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro&explaintext&redirects=1&titles=%s"
|
9 |
|
10 |
+
# 🔥 استخدام tokenizer بدون fast mode لتجنب المشاكل
|
11 |
+
tokenizer = MBartTokenizer.from_pretrained("facebook/mbart-large-50", use_fast=False)
|
12 |
+
summarizer = pipeline("summarization", model="facebook/mbart-large-50", tokenizer=tokenizer)
|
13 |
|
14 |
def search_wikipedia(query):
|
15 |
""" البحث في ويكيبيديا العربية وإرجاع ملخص من المقال الأول. """
|
|
|
69 |
|
70 |
if __name__ == "__main__":
|
71 |
demo.launch()
|
72 |
+
|