Update app.py
Browse files
app.py
CHANGED
@@ -3,9 +3,24 @@ from transformers import pipeline
|
|
3 |
from PIL import Image
|
4 |
import pytesseract
|
5 |
|
|
|
|
|
6 |
# Initialize chat model
|
7 |
chat_model = pipeline("text-generation", model="gpt2") # عدّل اسم النموذج حسب الحاجة
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
# Chat function
|
10 |
def chat_fn(history, user_input):
|
11 |
conversation = {"history": history, "user": user_input}
|
|
|
3 |
from PIL import Image
|
4 |
import pytesseract
|
5 |
|
6 |
+
huggingface-cli login
|
7 |
+
|
8 |
# Initialize chat model
|
9 |
chat_model = pipeline("text-generation", model="gpt2") # عدّل اسم النموذج حسب الحاجة
|
10 |
|
11 |
+
# Use a pipeline as a high-level helper
|
12 |
+
from transformers import pipeline
|
13 |
+
|
14 |
+
messages = [
|
15 |
+
{"role": "user", "content": "Who are you?"},
|
16 |
+
]
|
17 |
+
pipe = pipeline("text-generation", model="meta-llama/Llama-3.3-70B-Instruct")
|
18 |
+
pipe(messages)
|
19 |
+
# Load model directly
|
20 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
21 |
+
|
22 |
+
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.3-70B-Instruct")
|
23 |
+
model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.3-70B-Instruct")
|
24 |
# Chat function
|
25 |
def chat_fn(history, user_input):
|
26 |
conversation = {"history": history, "user": user_input}
|