Moonfanz commited on
Commit
78c3e27
·
verified ·
1 Parent(s): f24e251

Upload 4 files

Browse files
Files changed (1) hide show
  1. app.py +2 -2
app.py CHANGED
@@ -1,5 +1,5 @@
1
  from flask import Flask, request, jsonify, Response, stream_with_context, render_template_string
2
- from google.generativeai.types import StopCandidateException, generation_types
3
  from google.api_core.exceptions import InvalidArgument, ResourceExhausted, Aborted, InternalServerError, ServiceUnavailable, PermissionDenied
4
  import google.generativeai as genai
5
  import json
@@ -92,7 +92,7 @@ class ResponseWrapper:
92
  self._finish_reason = self._extract_finish_reason()
93
  if self.finish_reason != "STOP":
94
  # 抛出错误
95
- raise StopCandidateException(f"生成文本失败: {self.finish_reason}")
96
  self._prompt_token_count = self._extract_prompt_token_count()
97
  self._candidates_token_count = self._extract_candidates_token_count()
98
  self._total_token_count = self._extract_total_token_count()
 
1
  from flask import Flask, request, jsonify, Response, stream_with_context, render_template_string
2
+ from google.generativeai.types import StopCandidateException, generation_types, BlockedPromptException
3
  from google.api_core.exceptions import InvalidArgument, ResourceExhausted, Aborted, InternalServerError, ServiceUnavailable, PermissionDenied
4
  import google.generativeai as genai
5
  import json
 
92
  self._finish_reason = self._extract_finish_reason()
93
  if self.finish_reason != "STOP":
94
  # 抛出错误
95
+ raise BlockedPromptException(f"生成文本失败: {self.finish_reason}")
96
  self._prompt_token_count = self._extract_prompt_token_count()
97
  self._candidates_token_count = self._extract_candidates_token_count()
98
  self._total_token_count = self._extract_total_token_count()