Pepguy commited on
Commit
1351e15
·
verified ·
1 Parent(s): 34f1db4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -57,16 +57,16 @@ def generate_from_gemini(prompt: str) -> str:
57
  )
58
  ]
59
  config = types.GenerateContentConfig(response_mime_type="text/plain")
60
-
61
- result = []
62
- for chunk in client.models.generate_content_stream(
63
  model=model,
64
  contents=contents,
65
  config=config,
66
- ):
67
- result.append(chunk.text)
68
- return "".join(result)
69
-
70
  @app.route('/')
71
  def index():
72
  return render_template_string(HTML)
 
57
  )
58
  ]
59
  config = types.GenerateContentConfig(response_mime_type="text/plain")
60
+
61
+ # Synchronous, non-streaming call:
62
+ response = client.models.generate_content(
63
  model=model,
64
  contents=contents,
65
  config=config,
66
+ )
67
+ # The full text is in response.text
68
+ return response.text
69
+
70
  @app.route('/')
71
  def index():
72
  return render_template_string(HTML)