ramalMr commited on
Commit
cf4b1fe
·
verified ·
1 Parent(s): af15b12

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -57,15 +57,13 @@ def generate(file, prompt, temperature, max_new_tokens, top_p, repetition_penalt
57
  }
58
 
59
  try:
60
- output = 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=False, details=False, return_full_text=True)
 
 
 
 
61
  data.append({"original_sentence": sentence, "generated_data": output})
62
 
63
- except requests.exceptions.RequestException as e:
64
- print(f"Request error for sentence '{sentence}': {e}")
65
- except ValueError as e:
66
- print(f"Value error for sentence '{sentence}': {e}")
67
- except TypeError as e:
68
- print(f"Type error for sentence '{sentence}': {e}")
69
  except Exception as e:
70
  print(f"Error generating data for sentence '{sentence}': {e}")
71
 
 
57
  }
58
 
59
  try:
60
+ 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)
61
+ output = ""
62
+ for response in stream:
63
+ output += response.token.text
64
+
65
  data.append({"original_sentence": sentence, "generated_data": output})
66
 
 
 
 
 
 
 
67
  except Exception as e:
68
  print(f"Error generating data for sentence '{sentence}': {e}")
69