Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,18 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
# Setting up
|
| 5 |
-
# Using Qwen 2.5 3B - very powerful and free to use immediately
|
| 6 |
model_id = "Qwen/Qwen2.5-3B-Instruct"
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
def coretex_chat(user_input):
|
| 10 |
messages = [{"role": "user", "content": user_input}]
|
| 11 |
-
# Coretex
|
| 12 |
-
|
|
|
|
| 13 |
return response[0]['generated_text'][-1]['content']
|
| 14 |
|
| 15 |
-
# The interface humans see (we'll add the API for your bot later)
|
| 16 |
demo = gr.Interface(
|
| 17 |
fn=coretex_chat,
|
| 18 |
inputs=gr.Textbox(label="Message Coretex"),
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Setting up Coretex - Specifically for CPU Free Tier
|
|
|
|
| 5 |
model_id = "Qwen/Qwen2.5-3B-Instruct"
|
| 6 |
+
|
| 7 |
+
# We removed device_map="auto" to fix the error and added a simpler loader
|
| 8 |
+
pipe = pipeline(
|
| 9 |
+
"text-generation",
|
| 10 |
+
model=model_id,
|
| 11 |
+
model_kwargs={"low_cpu_mem_usage": True}
|
| 12 |
+
)
|
| 13 |
|
| 14 |
def coretex_chat(user_input):
|
| 15 |
messages = [{"role": "user", "content": user_input}]
|
| 16 |
+
# Coretex is thinking...
|
| 17 |
+
# Note: On CPU, this might take 10-20 seconds per answer.
|
| 18 |
+
response = pipe(messages, max_new_tokens=128)
|
| 19 |
return response[0]['generated_text'][-1]['content']
|
| 20 |
|
|
|
|
| 21 |
demo = gr.Interface(
|
| 22 |
fn=coretex_chat,
|
| 23 |
inputs=gr.Textbox(label="Message Coretex"),
|