Update app.py
Browse files
app.py
CHANGED
@@ -43,17 +43,12 @@ def generate(file, prompt, temperature, max_new_tokens, top_p, repetition_penalt
|
|
43 |
}
|
44 |
|
45 |
try:
|
46 |
-
stream = client.text_generation(f"{prompt} Output the response in the following JSON format: {{'generated_sentence': 'The generated sentence text', 'confidence_score': 0.9}}", **generate_kwargs, stream=True, details=True, return_full_text=False)
|
47 |
output = ""
|
48 |
for response in stream:
|
49 |
output += response.token.text
|
50 |
|
51 |
-
|
52 |
-
generated_data = json.loads(output)
|
53 |
-
data.append({"original_sentence": sentence, "generated_data": generated_data})
|
54 |
-
except json.JSONDecodeError:
|
55 |
-
print(f"Error decoding JSON for sentence '{sentence}': {output}")
|
56 |
-
data.append({"original_sentence": sentence, "generated_data": {"generated_sentence": output, "confidence_score": None}})
|
57 |
|
58 |
except Exception as e:
|
59 |
print(f"Error generating data for sentence '{sentence}': {e}")
|
|
|
43 |
}
|
44 |
|
45 |
try:
|
46 |
+
stream = client.text_generation(f"{prompt} Output the response in the following JSON format: {{'generated_sentence': 'The generated sentence text', 'confidence_score': 0.9}} {sentence}", **generate_kwargs, stream=True, details=True, return_full_text=False)
|
47 |
output = ""
|
48 |
for response in stream:
|
49 |
output += response.token.text
|
50 |
|
51 |
+
data.append({"original_sentence": sentence, "generated_data": output})
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
except Exception as e:
|
54 |
print(f"Error generating data for sentence '{sentence}': {e}")
|