Spaces:
Sleeping
Sleeping
prnvtripathi14
commited on
Commit
•
0e81368
1
Parent(s):
953f3ea
update
Browse files
app.py
CHANGED
@@ -31,9 +31,16 @@ def generate_test_cases(api_info):
|
|
31 |
f"Test cases should include:\n- Happy path\n- Negative tests\n- Edge cases"
|
32 |
)
|
33 |
# Tokenize the input prompt
|
34 |
-
inputs = tokenizer(prompt, return_tensors="pt", truncation=True)
|
|
|
35 |
# Generate output from the model
|
36 |
-
outputs = model.generate(
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
# Decode the generated text
|
38 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
39 |
logging.info("Test cases generated successfully.")
|
@@ -42,6 +49,7 @@ def generate_test_cases(api_info):
|
|
42 |
logging.error(f"Error generating test cases: {e}")
|
43 |
return "An error occurred while generating test cases."
|
44 |
|
|
|
45 |
# Process input and generate output
|
46 |
def process_input(url, method, headers, payload):
|
47 |
try:
|
|
|
31 |
f"Test cases should include:\n- Happy path\n- Negative tests\n- Edge cases"
|
32 |
)
|
33 |
# Tokenize the input prompt
|
34 |
+
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, padding=True)
|
35 |
+
|
36 |
# Generate output from the model
|
37 |
+
outputs = model.generate(
|
38 |
+
inputs["input_ids"],
|
39 |
+
attention_mask=inputs["attention_mask"], # Provide attention mask explicitly
|
40 |
+
max_length=512,
|
41 |
+
num_return_sequences=1,
|
42 |
+
do_sample=True
|
43 |
+
)
|
44 |
# Decode the generated text
|
45 |
generated_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
46 |
logging.info("Test cases generated successfully.")
|
|
|
49 |
logging.error(f"Error generating test cases: {e}")
|
50 |
return "An error occurred while generating test cases."
|
51 |
|
52 |
+
|
53 |
# Process input and generate output
|
54 |
def process_input(url, method, headers, payload):
|
55 |
try:
|