Create page3.py
Browse files
page3.py
ADDED
@@ -0,0 +1,328 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# import streamlit as st
|
2 |
+
#
|
3 |
+
# from langchain_google_genai import ChatGoogleGenerativeAI
|
4 |
+
#
|
5 |
+
# import time
|
6 |
+
# def details():
|
7 |
+
# apiKey = "AIzaSyC9ScRqi9g-YghNuS5w7o7Erwtd5RIN_Zo"
|
8 |
+
# llm = ChatGoogleGenerativeAI(model="gemini-2.0-flash-thinking-exp-01-21", google_api_key=apiKey)
|
9 |
+
# st.header("Introducing Gemini")
|
10 |
+
# with st.chat_message("assistant"):
|
11 |
+
# for chunk in llm.stream("Tell me about google gemini ai model"):
|
12 |
+
# st.write(chunk.content)
|
13 |
+
import time
|
14 |
+
|
15 |
+
import streamlit as st
|
16 |
+
|
17 |
+
# Ensure set_page_config is at the top
|
18 |
+
#st.set_page_config(page_title="Gemini 2.0 Flash Thinking", layout="wide")
|
19 |
+
|
20 |
+
def details():
|
21 |
+
st.empty()
|
22 |
+
chat = st.container()
|
23 |
+
chat.empty()
|
24 |
+
html_code = """
|
25 |
+
<!DOCTYPE html>
|
26 |
+
<html dir="ltr" lang="en">
|
27 |
+
<head>
|
28 |
+
<meta content="157101835696-ooapojlodmuabs2do2vuhhnf90bccmoi.apps.googleusercontent.com" name="google-signin-client-id"/>
|
29 |
+
<meta content="profile email https://www.googleapis.com/auth/developerprofiles https://www.googleapis.com/auth/developerprofiles.award" name="google-signin-scope"/>
|
30 |
+
<meta content="Google AI for Developers" property="og:site_name"/>
|
31 |
+
<meta content="website" property="og:type"/>
|
32 |
+
<meta content="#1967d2" name="theme-color"/>
|
33 |
+
<meta charset="utf-8"/>
|
34 |
+
<meta content="IE=Edge" http-equiv="X-UA-Compatible"/>
|
35 |
+
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
36 |
+
<link crossorigin="use-credentials" href="/_pwa/googledevai/manifest.json" rel="manifest"/>
|
37 |
+
<link crossorigin="" href="//www.gstatic.com" rel="preconnect"/>
|
38 |
+
<link crossorigin="" href="//fonts.gstatic.com" rel="preconnect"/>
|
39 |
+
<link crossorigin="" href="//fonts.googleapis.com" rel="preconnect"/>
|
40 |
+
<link crossorigin="" href="//apis.google.com" rel="preconnect"/>
|
41 |
+
<link crossorigin="" href="//www.google-analytics.com" rel="preconnect"/>
|
42 |
+
<link href="//fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap" rel="stylesheet"/>
|
43 |
+
<link href="//fonts.googleapis.com/css2?family=Material+Icons&family=Material+Symbols+Outlined&display=block" rel="stylesheet"/>
|
44 |
+
<link href="https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/css/app.css" rel="stylesheet"/>
|
45 |
+
<link disabled="" href="https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/css/dark-theme.css" rel="stylesheet"/>
|
46 |
+
<link href="https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/images/favicon-new.png" rel="shortcut icon"/>
|
47 |
+
<link href="https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/images/touchicon-180-new.png" rel="apple-touch-icon"/>
|
48 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking" rel="canonical"/>
|
49 |
+
<link href="https://ai.google.dev/s/opensearch.xml" rel="search" title="Google AI for Developers" type="application/opensearchdescription+xml"/>
|
50 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking" hreflang="en" rel="alternate">
|
51 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking" hreflang="x-default" rel="alternate">
|
52 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=ar" hreflang="ar" rel="alternate">
|
53 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=bn" hreflang="bn" rel="alternate">
|
54 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=zh-cn" hreflang="zh-Hans" rel="alternate">
|
55 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=zh-tw" hreflang="zh-Hant" rel="alternate">
|
56 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=fa" hreflang="fa" rel="alternate">
|
57 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=fr" hreflang="fr" rel="alternate">
|
58 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=de" hreflang="de" rel="alternate">
|
59 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=he" hreflang="he" rel="alternate">
|
60 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=hi" hreflang="hi" rel="alternate">
|
61 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=id" hreflang="id" rel="alternate">
|
62 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=it" hreflang="it" rel="alternate">
|
63 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=ja" hreflang="ja" rel="alternate">
|
64 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=ko" hreflang="ko" rel="alternate"/>
|
65 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=pl" hreflang="pl" rel="alternate"/>
|
66 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=pt-br" hreflang="pt-BR" rel="alternate"/>
|
67 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=ru" hreflang="ru" rel="alternate"/>
|
68 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=es-419" hreflang="es-419" rel="alternate"/>
|
69 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=th" hreflang="th" rel="alternate"/>
|
70 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=tr" hreflang="tr" rel="alternate"/>
|
71 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=vi" hreflang="vi" rel="alternate"/>
|
72 |
+
<link href="https://ai.google.dev/gemini-api/docs/thinking?hl=sq" hreflang="sq" rel="alternate"/>
|
73 |
+
<title>
|
74 |
+
Gemini 2.0 Flash Thinking | Gemini API | Google AI for Developers
|
75 |
+
</title>
|
76 |
+
<meta content="Gemini 2.0 Flash Thinking | Gemini API | Google AI for Developers" property="og:title"/>
|
77 |
+
<meta content="https://ai.google.dev/gemini-api/docs/thinking" property="og:url"/>
|
78 |
+
<meta content="https://ai.google.dev/static/site-assets/images/share-gemini-api.png" property="og:image"/>
|
79 |
+
<meta content="1200" property="og:image:width"/>
|
80 |
+
<meta content="675" property="og:image:height"/>
|
81 |
+
<meta content="en" property="og:locale"/>
|
82 |
+
<meta content="summary_large_image" name="twitter:card"/>
|
83 |
+
<script type="application/ld+json">
|
84 |
+
{
|
85 |
+
"@context": "https://schema.org",
|
86 |
+
"@type": "Article",
|
87 |
+
|
88 |
+
"headline": "Gemini 2.0 Flash Thinking"
|
89 |
+
}
|
90 |
+
</script>
|
91 |
+
<script type="application/ld+json">
|
92 |
+
{
|
93 |
+
"@context": "https://schema.org",
|
94 |
+
"@type": "BreadcrumbList",
|
95 |
+
"itemListElement": [{
|
96 |
+
"@type": "ListItem",
|
97 |
+
"position": 1,
|
98 |
+
"name": "Gemini API",
|
99 |
+
"item": "https://ai.google.dev/gemini-api"
|
100 |
+
},{
|
101 |
+
"@type": "ListItem",
|
102 |
+
"position": 2,
|
103 |
+
"name": "Gemini 2.0 Flash Thinking",
|
104 |
+
"item": "https://ai.google.dev/gemini-api/docs/thinking"
|
105 |
+
}]
|
106 |
+
}
|
107 |
+
</script>
|
108 |
+
<link href="/extras.css" rel="stylesheet"/>
|
109 |
+
</link>
|
110 |
+
</link>
|
111 |
+
</link>
|
112 |
+
</link>
|
113 |
+
</link>
|
114 |
+
</link>
|
115 |
+
</link>
|
116 |
+
</link>
|
117 |
+
</link>
|
118 |
+
</link>
|
119 |
+
</link>
|
120 |
+
</link>
|
121 |
+
</link>
|
122 |
+
</link>
|
123 |
+
</head>
|
124 |
+
<body appearance="" class="" display-toc="" layout="docs" pending="" template="page" theme="googledevai-theme" type="article">
|
125 |
+
<devsite-progress id="app-progress" type="indeterminate">
|
126 |
+
</devsite-progress>
|
127 |
+
<a class="skip-link button" href="#main-content">
|
128 |
+
Skip to main content
|
129 |
+
</a>
|
130 |
+
|
131 |
+
|
132 |
+
<section id="gc-wrapper">
|
133 |
+
<main class="devsite-main-content" id="main-content" role="main">
|
134 |
+
|
135 |
+
<devsite-content>
|
136 |
+
<article class="devsite-article">
|
137 |
+
|
138 |
+
|
139 |
+
<h1 class="devsite-page-title" tabindex="-1">
|
140 |
+
Gemini 2.0 Flash Thinking
|
141 |
+
<div class="devsite-actions" data-nosnippet="">
|
142 |
+
</div>
|
143 |
+
</h1>
|
144 |
+
<div class="devsite-page-title-meta">
|
145 |
+
<devsite-view-release-notes>
|
146 |
+
</devsite-view-release-notes>
|
147 |
+
</div>
|
148 |
+
<devsite-toc class="devsite-nav" depth="2" devsite-toc-embedded="">
|
149 |
+
</devsite-toc>
|
150 |
+
<div class="devsite-article-body clearfix">
|
151 |
+
<p>
|
152 |
+
</p>
|
153 |
+
<p>
|
154 |
+
The Gemini 2.0 Flash Thinking model is an experimental model that's trained to
|
155 |
+
generate the "thinking process" the model goes through as part of its response.
|
156 |
+
As a result, the Flash Thinking model is capable of stronger reasoning
|
157 |
+
capabilities in its responses than the Gemini 2.0 Flash Experimental model.
|
158 |
+
</p>
|
159 |
+
<div>
|
160 |
+
<a class="button button-primary ais" href="https://aistudio.google.com/prompts/new_chat?model=gemini-2.0-flash-thinking-exp-01-21">
|
161 |
+
Try the latest Flash Thinking model in Google AI Studio
|
162 |
+
</a>
|
163 |
+
</div>
|
164 |
+
<h2 data-text="Use thinking models" id="use-thinking-models" tabindex="-1">
|
165 |
+
Use thinking models
|
166 |
+
</h2>
|
167 |
+
<p>
|
168 |
+
Flash Thinking models are available in
|
169 |
+
<a href="https://aistudio.google.com/prompts/new_chat?model=gemini-2.0-flash-thinking-exp-01-21">
|
170 |
+
Google AI Studio
|
171 |
+
</a>
|
172 |
+
and through the Gemini API. The Gemini API doesn't return thoughts in the response.
|
173 |
+
</p>
|
174 |
+
<aside class="note">
|
175 |
+
<strong>
|
176 |
+
Note:
|
177 |
+
</strong>
|
178 |
+
<span>
|
179 |
+
We have set up
|
180 |
+
<code dir="ltr" translate="no">
|
181 |
+
gemini-2.0-flash-thinking-exp
|
182 |
+
</code>
|
183 |
+
as an alias to the latest
|
184 |
+
Flash Thinking model. Use this alias to get the latest Flash thinking model, or
|
185 |
+
specify the full model name.
|
186 |
+
</span>
|
187 |
+
</aside>
|
188 |
+
<h3 data-text="Send a basic request" id="send-basic" tabindex="-1">
|
189 |
+
Send a basic request
|
190 |
+
</h3>
|
191 |
+
<div class="ds-selector-tabs" data-ds-scope="code-sample">
|
192 |
+
<section>
|
193 |
+
<h3 data-text="Python" id="python" tabindex="-1">
|
194 |
+
Python
|
195 |
+
</h3>
|
196 |
+
<p>
|
197 |
+
This example uses the new
|
198 |
+
<a href="/gemini-api/docs/sdks#python-quickstart">
|
199 |
+
Google Genai SDK
|
200 |
+
</a>
|
201 |
+
and the
|
202 |
+
<code dir="ltr" translate="no">
|
203 |
+
v1alpha
|
204 |
+
</code>
|
205 |
+
version of the API.
|
206 |
+
</p>
|
207 |
+
<div>
|
208 |
+
</div>
|
209 |
+
<devsite-code>
|
210 |
+
<pre class="devsite-click-to-copy" dir="ltr" is-upgraded="" syntax="Python" translate="no"><code dir="ltr" translate="no"><span class="devsite-syntax-kn">from</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nn">google</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">genai</span>
|
211 |
+
|
212 |
+
<span class="devsite-syntax-n">client</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">genai</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">Client</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">api_key</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s1">'GEMINI_API_KEY'</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">http_options</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-s1">'api_version'</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-s1">'v1alpha'</span><span class="devsite-syntax-p">})</span>
|
213 |
+
|
214 |
+
<span class="devsite-syntax-n">response</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">client</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">models</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">generate_content</span><span class="devsite-syntax-p">(</span>
|
215 |
+
<span class="devsite-syntax-n">model</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s1">'gemini-2.0-flash-thinking-exp'</span><span class="devsite-syntax-p">,</span>
|
216 |
+
<span class="devsite-syntax-n">contents</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s1">'Explain how RLHF works in simple terms.'</span><span class="devsite-syntax-p">,</span>
|
217 |
+
<span class="devsite-syntax-p">)</span>
|
218 |
+
|
219 |
+
<span class="devsite-syntax-nb">print</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">response</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">text</span><span class="devsite-syntax-p">)</span>
|
220 |
+
</code></pre>
|
221 |
+
</devsite-code>
|
222 |
+
</section>
|
223 |
+
</div>
|
224 |
+
<h3 data-text="Multi-turn thinking conversations" id="multi-turn-thinking" tabindex="-1">
|
225 |
+
Multi-turn thinking conversations
|
226 |
+
</h3>
|
227 |
+
<p>
|
228 |
+
During multi-turn conversations, thoughts from previous turns are stripped from
|
229 |
+
the model's inputs.
|
230 |
+
</p>
|
231 |
+
<div class="ds-selector-tabs" data-ds-scope="code-sample">
|
232 |
+
<section>
|
233 |
+
<h3 data-text="Python" id="python_1" tabindex="-1">
|
234 |
+
Python
|
235 |
+
</h3>
|
236 |
+
<p>
|
237 |
+
The new
|
238 |
+
<a href="/gemini-api/docs/sdks#python-quickstart">
|
239 |
+
Google Genai SDK
|
240 |
+
</a>
|
241 |
+
provides the ability to create a multi-turn chat session which is
|
242 |
+
helpful to manage the state of a conversation.
|
243 |
+
</p>
|
244 |
+
<div>
|
245 |
+
</div>
|
246 |
+
<devsite-code>
|
247 |
+
<pre class="devsite-click-to-copy" dir="ltr" is-upgraded="" syntax="Python" translate="no"><code dir="ltr" translate="no"><span class="devsite-syntax-kn">from</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-nn">google</span><span class="devsite-syntax-w"> </span><span class="devsite-syntax-kn">import</span> <span class="devsite-syntax-n">genai</span>
|
248 |
+
|
249 |
+
<span class="devsite-syntax-n">client</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">genai</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">Client</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">api_key</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s1">'GEMINI_API_KEY'</span><span class="devsite-syntax-p">,</span> <span class="devsite-syntax-n">http_options</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-p">{</span><span class="devsite-syntax-s1">'api_version'</span><span class="devsite-syntax-p">:</span><span class="devsite-syntax-s1">'v1alpha'</span><span class="devsite-syntax-p">})</span>
|
250 |
+
|
251 |
+
<span class="devsite-syntax-n">chat</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-n">client</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">aio</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">chats</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">create</span><span class="devsite-syntax-p">(</span>
|
252 |
+
<span class="devsite-syntax-n">model</span><span class="devsite-syntax-o">=</span><span class="devsite-syntax-s1">'gemini-2.0-flash-thinking-exp'</span><span class="devsite-syntax-p">,</span>
|
253 |
+
<span class="devsite-syntax-p">)</span>
|
254 |
+
<span class="devsite-syntax-n">response</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-k">await</span> <span class="devsite-syntax-n">chat</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">send_message</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s1">'What is your name?'</span><span class="devsite-syntax-p">)</span>
|
255 |
+
<span class="devsite-syntax-nb">print</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">response</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">text</span><span class="devsite-syntax-p">)</span>
|
256 |
+
<span class="devsite-syntax-n">response</span> <span class="devsite-syntax-o">=</span> <span class="devsite-syntax-k">await</span> <span class="devsite-syntax-n">chat</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">send_message</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-s1">'What did you just say before this?'</span><span class="devsite-syntax-p">)</span>
|
257 |
+
<span class="devsite-syntax-nb">print</span><span class="devsite-syntax-p">(</span><span class="devsite-syntax-n">response</span><span class="devsite-syntax-o">.</span><span class="devsite-syntax-n">text</span><span class="devsite-syntax-p">)</span>
|
258 |
+
</code></pre>
|
259 |
+
</devsite-code>
|
260 |
+
</section>
|
261 |
+
</div>
|
262 |
+
<h2 data-text="Limitations" id="limitations" tabindex="-1">
|
263 |
+
Limitations
|
264 |
+
</h2>
|
265 |
+
<p>
|
266 |
+
The Flash Thinking model is an experimental model and has the following
|
267 |
+
limitations:
|
268 |
+
</p>
|
269 |
+
<ul>
|
270 |
+
<li>
|
271 |
+
No JSON mode or Search Grounding
|
272 |
+
</li>
|
273 |
+
<li>
|
274 |
+
Thoughts are only shown in Google AI Studio
|
275 |
+
</li>
|
276 |
+
</ul>
|
277 |
+
<h2 data-text="What's next?" id="whats-next" tabindex="-1">
|
278 |
+
What's next?
|
279 |
+
</h2>
|
280 |
+
<ul>
|
281 |
+
<li>
|
282 |
+
Try the Flash Thinking model in
|
283 |
+
<a href="https://aistudio.google.com/prompts/new_chat?model=gemini-2.0-flash-thinking-exp-01-21">
|
284 |
+
Google AI Studio
|
285 |
+
</a>
|
286 |
+
.
|
287 |
+
</li>
|
288 |
+
<li>
|
289 |
+
Try the
|
290 |
+
<a href="https://colab.sandbox.google.com/github/google-gemini/cookbook/blob/main/quickstarts/Get_started_thinking.ipynb">
|
291 |
+
Flash Thinking Colab
|
292 |
+
</a>
|
293 |
+
.
|
294 |
+
</li>
|
295 |
+
</ul>
|
296 |
+
<link data-page-link="" href="/site-assets/css/style.css?v=3" rel="stylesheet"/>
|
297 |
+
<link data-page-link="" href="https://fonts.googleapis.com/css2?family=Google+Symbols:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" rel="stylesheet"/>
|
298 |
+
</div>
|
299 |
+
</article>
|
300 |
+
</main>
|
301 |
+
|
302 |
+
<script nonce="JcFvBGdkcv/1Vce7ZjN/RLoNxR4Uj2">
|
303 |
+
(function(d,e,v,s,i,t,E){d['GoogleDevelopersObject']=i;
|
304 |
+
t=e.createElement(v);t.async=1;t.src=s;E=e.getElementsByTagName(v)[0];
|
305 |
+
E.parentNode.insertBefore(t,E);})(window, document, 'script',
|
306 |
+
'https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/js/app_loader.js', '[59,"en",null,"/js/devsite_app_module.js","https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933","https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai","https://googledevai-dot-devsite-v2-prod-3p.appspot.com",null,null,["/_pwa/googledevai/manifest.json","https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/images/video-placeholder.svg","https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/images/favicon-new.png","https://www.gstatic.com/devrel-devsite/prod/v17c4f87be230ffee20589ee6dca0a2318ead9eddb228ec5c58233202ff69a933/googledevai/images/lockup-new.svg","https://fonts.googleapis.com/css?family=Google+Sans:400,500|Roboto:400,400italic,500,500italic,700,700italic|Roboto+Mono:400,500,700&display=swap"],1,null,[1,6,8,12,14,17,21,25,50,52,63,70,75,76,80,87,91,92,93,97,98,100,101,102,103,104,105,107,108,109,110,112,113,116,117,118,120,122,124,125,126,127,129,130,131,132,133,134,135,136,138,140,141,147,148,149,151,152,156,157,158,159,161,163,164,168,169,170,179,180,182,183,186,191,193,196],"AIzaSyCNm9YxQumEXwGJgTDjxoxXK6m1F-9720Q","AIzaSyCc76DZePGtoyUjqKrLdsMGk_ry7sljLbY","ai.google.dev","AIzaSyB9bqgQ2t11WJsOX8qNsCQ6U-w91mmqF-I","AIzaSyAdYnStPdzjcJJtQ0mvIaeaMKj7_t6J_Fg",null,null,null,["Search__enable_ai_eligibility_checks","Concierge__enable_actions_menu","DevPro__enable_developer_subscriptions","MiscFeatureFlags__enable_project_variables","Cloud__enable_llm_concierge_chat","MiscFeatureFlags__developers_footer_dark_image","MiscFeatureFlags__emergency_css","MiscFeatureFlags__developers_footer_image","MiscFeatureFlags__enable_framebox_badge_methods","Profiles__enable_page_saving","MiscFeatureFlags__enable_explain_this_code","Cloud__enable_cloud_shell_fte_user_flow","DevPro__enable_cloud_innovators_plus","Cloud__enable_cloud_shell","Concierge__enable_pushui","MiscFeatureFlags__enable_view_transitions","BookNav__enable_tenant_cache_key","CloudShell__cloud_shell_button","Cloud__enable_cloud_dlp_service","TpcFeatures__enable_unmirrored_page_left_nav","Profiles__enable_completecodelab_endpoint","Profiles__enable_profile_collections","Profiles__enable_recognition_badges","OnSwitch__enable","Profiles__enable_completequiz_endpoint","Cloud__enable_free_trial_server_call","Search__enable_page_map","Profiles__enable_stripe_subscription_management","DevPro__enable_devpro_offers","Cloud__enable_legacy_calculator_redirect","MiscFeatureFlags__enable_firebase_utm","Experiments__reqs_query_experiments","Analytics__enable_clearcut_logging","Cloud__enable_cloud_facet_chat","Profiles__enable_release_notes_notifications","MiscFeatureFlags__enable_variable_operator_index_yaml","Search__enable_suggestions_from_borg","Profiles__enable_join_program_group_endpoint","Profiles__enable_awarding_url","Profiles__enable_public_developer_profiles","Profiles__enable_developer_profiles_callout","Cloud__enable_cloudx_ping","TpcFeatures__enable_mirror_tenant_redirects","MiscFeatureFlags__enable_variable_operator","Profiles__require_profile_eligibility_for_signin","Profiles__enable_complete_playlist_endpoint","CloudShell__cloud_code_overflow_menu","Profiles__enable_dashboard_curated_recommendations","Cloud__enable_cloudx_experiment_ids","Search__enable_dynamic_content_confidential_banner","EngEduTelemetry__enable_engedu_telemetry"],null,null,"AIzaSyA58TaKli1DculwmAmbpzLVGuWc8eCQgQc","https://developerscontentserving-pa.googleapis.com","AIzaSyDWBU60w0P9hEkr29kkksYs8Z7gvZ8u_wc","https://developerscontentsearch-pa.googleapis.com",2,4,null,"https://developerprofiles-pa.googleapis.com",[59,"googledevai","Google AI for Developers","ai.google.dev",null,"googledevai-dot-devsite-v2-prod-3p.appspot.com",null,null,[null,1,null,null,null,null,null,null,null,null,null,[1],null,null,null,null,null,null,[1],null,null,null,null,[1],[1,1,null,1,1]],null,[73,null,null,null,null,null,"/images/lockup-new.svg","/images/touchicon-180-new.png",null,null,null,1,1,1,null,null,null,null,null,null,null,2,null,null,null,"/images/lockup-dark-theme-new.svg",[]],[],null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,[44,2,4,6,7,12,14,15,17,18,20,21,22,23,28,29,32,37,39,40,43],null,[[],[1,1],null,1],[[null,null,null,null,null,["GTM-TC2MQKS8"],null,null,null,null,null,[["GTM-TC2MQKS8",1]],1]],null,4],null,null,1,1,"https://developerscontentinsights-pa.googleapis.com","AIzaSyBUwhBSZ2D08LlB5muaB5af2QQjzrjYbIw"]')
|
307 |
+
</script>
|
308 |
+
<devsite-a11y-announce>
|
309 |
+
</devsite-a11y-announce>
|
310 |
+
</body>
|
311 |
+
</html>
|
312 |
+
|
313 |
+
"""
|
314 |
+
data = f'''**Gemini 2.0 Flash Thinking** \n\nThe Gemini 2.0 Flash Thinking model is an experimental model that's trained to generate the "thinking process" the model goes through as part of its response. As a result, the Flash Thinking model is capable of stronger reasoning capabilities in its responses than the Gemini 2.0 Flash Experimental model.\n\n**Use thinking models**\n\nFlash Thinking models are available in Google AI Studio and through the Gemini API. The Gemini API doesn't return thoughts in the response.\n\nNote: The set up for gemini-2.0-flash-thinking-exp as an alias to the latest Flash Thinking model. Use this alias to get the latest Flash thinking model, or specify the full model name. \n\n**Send a basic request**\n\nThis example uses the new Google Genai SDK and the v1alpha version of the API.\n ```python\n from google import genai\nclient = genai.Client(api_key='GEMINI_API_KEY', http_options='api_version':'v1alpha')\nresponse = client.models.generate_content(\nmodel='gemini-2.0-flash-thinking-exp',\ncontents='Explain how RLHF works in simple terms.',\n)\nprint(response.text)\n```\n**Multi-turn thinking conversations**\n\nDuring multi-turn conversations, thoughts from previous turns are stripped from the model's inputs.\nThe new Google Genai SDK provides the ability to create a multi-turn chat session which is helpful to manage the state of a conversation.\n```python\nfrom google import genai\nclient = genai.Client(api_key='GEMINI_API_KEY', http_options='api_version':'v1alpha')\nchat = client.aio.chats.create(\nmodel='gemini-2.0-flash-thinking-exp',\n)\nresponse = await chat.send_message('What is your name?')\nprint(response.text)\nresponse = await chat.send_message('What did you just say before this?')\nprint(response.text)\n```\n\n**Limitations**\n\nThe Flash Thinking model is an experimental model and has the following limitations:\n\n\tNo JSON mode or Search Grounding\n\tThoughts are only shown in Google AI Studio'''
|
315 |
+
|
316 |
+
def stream_data():
|
317 |
+
for word in data.split(" "):
|
318 |
+
yield word + " "
|
319 |
+
time.sleep(0.02)
|
320 |
+
|
321 |
+
|
322 |
+
time.sleep(3)
|
323 |
+
with st.chat_message("assistant", avatar="🤖"):
|
324 |
+
st.write_stream(stream_data)
|
325 |
+
# Use st.components.v1.html to render full HTML layout properly
|
326 |
+
#st.components.v1.html(html_code, height=800, scrolling=True)
|
327 |
+
#st.chat_message("user", avatar="🧑").markdown(f'''**Gemini 2.0 Flash Thinking** \n\nThe Gemini 2.0 Flash Thinking model is an experimental model that's trained to generate the "thinking process" the model goes through as part of its response. As a result, the Flash Thinking model is capable of stronger reasoning capabilities in its responses than the Gemini 2.0 Flash Experimental model.\n\n**Use thinking models**\n\nFlash Thinking models are available in Google AI Studio and through the Gemini API. The Gemini API doesn't return thoughts in the response.\n\nNote: The set up for gemini-2.0-flash-thinking-exp as an alias to the latest Flash Thinking model. Use this alias to get the latest Flash thinking model, or specify the full model name. \n\n**Send a basic request**\n\nThis example uses the new Google Genai SDK and the v1alpha version of the API.\n ```python\n from google import genai\nclient = genai.Client(api_key='GEMINI_API_KEY', http_options='api_version':'v1alpha')\nresponse = client.models.generate_content(\nmodel='gemini-2.0-flash-thinking-exp',\ncontents='Explain how RLHF works in simple terms.',\n)\nprint(response.text)\n```\n**Multi-turn thinking conversations**\n\nDuring multi-turn conversations, thoughts from previous turns are stripped from the model's inputs.\nThe new Google Genai SDK provides the ability to create a multi-turn chat session which is helpful to manage the state of a conversation.\n```python\nfrom google import genai\nclient = genai.Client(api_key='GEMINI_API_KEY', http_options='api_version':'v1alpha')\nchat = client.aio.chats.create(\nmodel='gemini-2.0-flash-thinking-exp',\n)\nresponse = await chat.send_message('What is your name?')\nprint(response.text)\nresponse = await chat.send_message('What did you just say before this?')\nprint(response.text)\n```\n\n**Limitations**\n\nThe Flash Thinking model is an experimental model and has the following limitations:\n\n\tNo JSON mode or Search Grounding\n\tThoughts are only shown in Google AI Studio''')
|
328 |
+
|