Spaces:
Building
Building
Upload 2 files
Browse files
app.py
CHANGED
@@ -90,8 +90,6 @@ class ResponseWrapper:
|
|
90 |
self._data = data
|
91 |
self._text = self._extract_text()
|
92 |
self._finish_reason = self._extract_finish_reason()
|
93 |
-
if self.finish_reason != "STOP":
|
94 |
-
raise BlockedPromptException(f"用户输入或AI输出被安全系统阻止: {self.finish_reason}")
|
95 |
self._prompt_token_count = self._extract_prompt_token_count()
|
96 |
self._candidates_token_count = self._extract_candidates_token_count()
|
97 |
self._total_token_count = self._extract_total_token_count()
|
@@ -103,9 +101,9 @@ class ResponseWrapper:
|
|
103 |
for part in self._data['candidates'][0]['content']['parts']:
|
104 |
if 'thought' in part:
|
105 |
return part['text']
|
106 |
-
return
|
107 |
except (KeyError, IndexError):
|
108 |
-
return
|
109 |
|
110 |
def _extract_text(self) -> str:
|
111 |
try:
|
|
|
90 |
self._data = data
|
91 |
self._text = self._extract_text()
|
92 |
self._finish_reason = self._extract_finish_reason()
|
|
|
|
|
93 |
self._prompt_token_count = self._extract_prompt_token_count()
|
94 |
self._candidates_token_count = self._extract_candidates_token_count()
|
95 |
self._total_token_count = self._extract_total_token_count()
|
|
|
101 |
for part in self._data['candidates'][0]['content']['parts']:
|
102 |
if 'thought' in part:
|
103 |
return part['text']
|
104 |
+
return ""
|
105 |
except (KeyError, IndexError):
|
106 |
+
return ""
|
107 |
|
108 |
def _extract_text(self) -> str:
|
109 |
try:
|
func.py
CHANGED
@@ -27,8 +27,6 @@ def authenticate_request(request):
|
|
27 |
|
28 |
return True, None, None
|
29 |
|
30 |
-
from flask import jsonify
|
31 |
-
|
32 |
def process_messages_for_gemini(messages):
|
33 |
gemini_history = []
|
34 |
errors = []
|
|
|
27 |
|
28 |
return True, None, None
|
29 |
|
|
|
|
|
30 |
def process_messages_for_gemini(messages):
|
31 |
gemini_history = []
|
32 |
errors = []
|