Spaces:
Runtime error
Runtime error
Sidharthan
commited on
Commit
•
a892c2b
1
Parent(s):
e6db8ab
Changed the device configuration to solve issues
Browse files
app.py
CHANGED
@@ -24,7 +24,7 @@ try:
|
|
24 |
)
|
25 |
model = AutoPeftModelForCausalLM.from_pretrained(
|
26 |
MODEL_NAME,
|
27 |
-
device_map=
|
28 |
trust_remote_code=True,
|
29 |
cache_dir = '/app/cache'
|
30 |
#load_in_4bit=True
|
|
|
24 |
)
|
25 |
model = AutoPeftModelForCausalLM.from_pretrained(
|
26 |
MODEL_NAME,
|
27 |
+
device_map=None, # Will use CPU if GPU not available
|
28 |
trust_remote_code=True,
|
29 |
cache_dir = '/app/cache'
|
30 |
#load_in_4bit=True
|
test.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import requests
|
2 |
+
|
3 |
+
# Replace with your actual Space URL
|
4 |
+
API_URL = "https://sidharthan-scriptr.hf.space/generate"
|
5 |
+
|
6 |
+
def test_single_request():
|
7 |
+
# Test data
|
8 |
+
test_prompt = """
|
9 |
+
<bos><start_of_turn>user
|
10 |
+
how are you?
|
11 |
+
<start_of_turn>model
|
12 |
+
"""
|
13 |
+
|
14 |
+
# Make request
|
15 |
+
try:
|
16 |
+
response = requests.post(
|
17 |
+
API_URL,
|
18 |
+
json={
|
19 |
+
"message": test_prompt,
|
20 |
+
"temperature": 0.7,
|
21 |
+
"max_length": 512
|
22 |
+
}
|
23 |
+
)
|
24 |
+
|
25 |
+
# Print results
|
26 |
+
print(f"Status Code: {response.status_code}")
|
27 |
+
if response.status_code == 200:
|
28 |
+
print("\nGenerated Text:")
|
29 |
+
print(response.json()['generated_text'])
|
30 |
+
else:
|
31 |
+
print(f"Error: {response.text}")
|
32 |
+
|
33 |
+
except Exception as e:
|
34 |
+
print(f"Error making request: {str(e)}")
|
35 |
+
|
36 |
+
if __name__ == "__main__":
|
37 |
+
test_single_request()
|