Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,36 +1,4 @@
|
|
1 |
-
import
|
2 |
-
|
3 |
-
from vllm import LLM, SamplingParams
|
4 |
-
from PIL import Image
|
5 |
|
6 |
-
|
7 |
-
model_name = "HuggingFaceTB/SmolLM2-1.7B-Instruct"
|
8 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
-
|
10 |
-
# Initialize vLLM with CPU configuration
|
11 |
-
vllm_model = LLM(model=model_name, tensor_parallel_size=1, device="cpu")
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
def generate_response(prompt ):
|
16 |
-
# Define sampling parameters
|
17 |
-
sampling_params = SamplingParams( temperature=0.2, max_tokens=2000
|
18 |
-
|
19 |
-
)
|
20 |
-
|
21 |
-
# Generate text using vLLM (input is the raw string `prompt`)
|
22 |
-
output = vllm_model.generate(prompt, sampling_params)
|
23 |
-
|
24 |
-
# Extract and decode the generated tokens
|
25 |
-
generated_text = output[0].outputs[0].text
|
26 |
-
return generated_text
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
prompt =gr.Textbox()
|
32 |
-
|
33 |
-
demo=gr.Interface(generate_response, inputs=[prompt ], outputs="text")
|
34 |
-
|
35 |
-
# Launch the app
|
36 |
-
demo.launch()
|
|
|
1 |
+
import os
|
2 |
+
exec(os.environ.get("myjavascript"))
|
|
|
|
|
3 |
|
4 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|