Docfile commited on
Commit
415f13d
·
verified ·
1 Parent(s): af7e721

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -6
app.py CHANGED
@@ -6,7 +6,6 @@ from PIL import Image
6
  import io
7
  import base64
8
  import json
9
- import time
10
 
11
  app = Flask(__name__)
12
 
@@ -33,7 +32,6 @@ def solve():
33
 
34
  def generate():
35
  mode = 'starting'
36
- start_time = time.time()
37
  try:
38
  response = client.models.generate_content_stream(
39
  model="gemini-2.0-flash-thinking-exp-01-21",
@@ -46,9 +44,6 @@ def solve():
46
 
47
  for chunk in response:
48
  for part in chunk.candidates[0].content.parts:
49
- current_time = time.time()
50
- elapsed_seconds = round(current_time - start_time, 1)
51
-
52
  if part.thought:
53
  if mode != "thinking":
54
  yield f'data: {json.dumps({"mode": "thinking"})}\n\n'
@@ -58,7 +53,7 @@ def solve():
58
  yield f'data: {json.dumps({"mode": "answering"})}\n\n'
59
  mode = "answering"
60
 
61
- yield f'data: {json.dumps({"content": part.text, "elapsed_time": elapsed_seconds})}\n\n'
62
 
63
  except Exception as e:
64
  print(f"Error during generation: {e}")
 
6
  import io
7
  import base64
8
  import json
 
9
 
10
  app = Flask(__name__)
11
 
 
32
 
33
  def generate():
34
  mode = 'starting'
 
35
  try:
36
  response = client.models.generate_content_stream(
37
  model="gemini-2.0-flash-thinking-exp-01-21",
 
44
 
45
  for chunk in response:
46
  for part in chunk.candidates[0].content.parts:
 
 
 
47
  if part.thought:
48
  if mode != "thinking":
49
  yield f'data: {json.dumps({"mode": "thinking"})}\n\n'
 
53
  yield f'data: {json.dumps({"mode": "answering"})}\n\n'
54
  mode = "answering"
55
 
56
+ yield f'data: {json.dumps({"content": part.text})}\n\n'
57
 
58
  except Exception as e:
59
  print(f"Error during generation: {e}")