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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -57,13 +57,15 @@ def generate(file, prompt, temperature, max_new_tokens, top_p, repetition_penalt
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
 
 
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