Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,20 +10,7 @@ from unsloth import FastLanguageModel
|
|
| 10 |
import torch
|
| 11 |
import re
|
| 12 |
|
| 13 |
-
# Load the model
|
| 14 |
-
max_seq_length = 2048
|
| 15 |
-
dtype = None
|
| 16 |
-
load_in_4bit = True
|
| 17 |
-
|
| 18 |
-
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 19 |
-
model_name="unsloth/mistral-7b-instruct-v0.3-bnb-4bit",
|
| 20 |
-
max_seq_length=max_seq_length,
|
| 21 |
-
dtype=dtype,
|
| 22 |
-
load_in_4bit=load_in_4bit,
|
| 23 |
-
)
|
| 24 |
|
| 25 |
-
# Enable native 2x faster inference
|
| 26 |
-
FastLanguageModel.for_inference(model)
|
| 27 |
|
| 28 |
# Define helper functions
|
| 29 |
async def fetch_data(url):
|
|
@@ -115,7 +102,24 @@ def translate_text(text):
|
|
| 115 |
print(f"An error occurred during translation: {e}")
|
| 116 |
return None
|
| 117 |
|
|
|
|
| 118 |
def summarize_url(url):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
result = asyncio.run(fetch_data(url))
|
| 120 |
text = concatenate_text(result)
|
| 121 |
translated_text = translate_text(text)
|
|
|
|
| 10 |
import torch
|
| 11 |
import re
|
| 12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
|
|
|
|
|
|
|
| 14 |
|
| 15 |
# Define helper functions
|
| 16 |
async def fetch_data(url):
|
|
|
|
| 102 |
print(f"An error occurred during translation: {e}")
|
| 103 |
return None
|
| 104 |
|
| 105 |
+
@spaces.GPU()
|
| 106 |
def summarize_url(url):
|
| 107 |
+
|
| 108 |
+
# Load the model
|
| 109 |
+
max_seq_length = 2048
|
| 110 |
+
dtype = None
|
| 111 |
+
load_in_4bit = True
|
| 112 |
+
|
| 113 |
+
model, tokenizer = FastLanguageModel.from_pretrained(
|
| 114 |
+
model_name="unsloth/mistral-7b-instruct-v0.3-bnb-4bit",
|
| 115 |
+
max_seq_length=max_seq_length,
|
| 116 |
+
dtype=dtype,
|
| 117 |
+
load_in_4bit=load_in_4bit,
|
| 118 |
+
)
|
| 119 |
+
|
| 120 |
+
# Enable native 2x faster inference
|
| 121 |
+
FastLanguageModel.for_inference(model)
|
| 122 |
+
|
| 123 |
result = asyncio.run(fetch_data(url))
|
| 124 |
text = concatenate_text(result)
|
| 125 |
translated_text = translate_text(text)
|