Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -35,10 +35,24 @@ except Exception as e:
|
|
35 |
# Function to generate a response from the model
|
36 |
def generate_response(user_input):
|
37 |
try:
|
|
|
38 |
messages = [{"role": "user", "content": user_input}]
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
output_ids = model.generate(input_ids.to('cuda'))
|
|
|
|
|
41 |
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
|
|
|
|
|
42 |
return response
|
43 |
except Exception as e:
|
44 |
print(f"Error generating response: {e}")
|
|
|
35 |
# Function to generate a response from the model
|
36 |
def generate_response(user_input):
|
37 |
try:
|
38 |
+
print(f"User input: {user_input}")
|
39 |
messages = [{"role": "user", "content": user_input}]
|
40 |
+
print(f"Messages: {messages}")
|
41 |
+
|
42 |
+
input_ids = tokenizer.apply_chat_template(
|
43 |
+
conversation=messages,
|
44 |
+
tokenize=True,
|
45 |
+
add_generation_prompt=True,
|
46 |
+
return_tensors='pt'
|
47 |
+
)
|
48 |
+
print(f"Input IDs: {input_ids}")
|
49 |
+
|
50 |
output_ids = model.generate(input_ids.to('cuda'))
|
51 |
+
print(f"Output IDs: {output_ids}")
|
52 |
+
|
53 |
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
|
54 |
+
print(f"Response: {response}")
|
55 |
+
|
56 |
return response
|
57 |
except Exception as e:
|
58 |
print(f"Error generating response: {e}")
|