Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
| 1 |
#pip3 install googletrans==4.0.0-rc1
|
| 2 |
-
|
| 3 |
import gradio as gr
|
| 4 |
from google import genai
|
| 5 |
import os
|
|
@@ -12,7 +11,7 @@ async def generate_content(prompt):
|
|
| 12 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 13 |
config = {'thinking_config': {'include_thoughts': True}}
|
| 14 |
response = client.models.generate_content(
|
| 15 |
-
#model="gemini-2.
|
| 16 |
model='gemini-2.0-flash-thinking-exp',
|
| 17 |
contents=prompt,
|
| 18 |
config=config
|
|
@@ -30,18 +29,13 @@ async def generate_content(prompt):
|
|
| 30 |
continue
|
| 31 |
translated_text = await translator.translate(part.text, src='en', dest='ja')
|
| 32 |
if part.thought:
|
| 33 |
-
print("่ใใฎ่ฆ็ด:")
|
| 34 |
-
print(translated_text)
|
| 35 |
-
print()
|
| 36 |
summary_thought += translated_text.text
|
| 37 |
else:
|
| 38 |
-
print("็ญใ:")
|
| 39 |
-
print(translated_text)
|
| 40 |
-
print()
|
| 41 |
summary_answer += translated_text.text
|
| 42 |
|
| 43 |
summaries = summary_thought + '\n' + summary_answer
|
| 44 |
-
|
|
|
|
| 45 |
|
| 46 |
# Gradio Blocksใฎ่จญๅฎ
|
| 47 |
with gr.Blocks(title="gemini think",css="footer {visibility: hidden;} #header {display: flex; justify-content: space-between; align-items: center; font-size: 24px; font-weight: bold;} #logo {width: 50px; height: 50px;} .logout-btn { background-color: #3498db; border-radius: 10px; color: white; padding: 10px 20px; border: none; cursor: pointer; transparent-bg {background-color: transparent; color: black; padding: 10px; border: none;}") as gemini:
|
|
@@ -95,9 +89,9 @@ with gr.Blocks(title="gemini think",css="footer {visibility: hidden;} #header {d
|
|
| 95 |
''')
|
| 96 |
|
| 97 |
with gr.Row():
|
| 98 |
-
prompt_input = gr.Textbox(label="ใใญใณใใใๅ
ฅๅใใฆใใ ใใ", info="ไพ:
|
| 99 |
-
output_text = gr.Textbox(label="็ๆใใใ
|
| 100 |
-
summary_text = gr.Textbox(label="
|
| 101 |
|
| 102 |
with gr.Row():
|
| 103 |
generate_button = gr.Button("็ๆ")
|
|
|
|
| 1 |
#pip3 install googletrans==4.0.0-rc1
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from google import genai
|
| 4 |
import os
|
|
|
|
| 11 |
client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
|
| 12 |
config = {'thinking_config': {'include_thoughts': True}}
|
| 13 |
response = client.models.generate_content(
|
| 14 |
+
#model="gemini-2.5-flash",
|
| 15 |
model='gemini-2.0-flash-thinking-exp',
|
| 16 |
contents=prompt,
|
| 17 |
config=config
|
|
|
|
| 29 |
continue
|
| 30 |
translated_text = await translator.translate(part.text, src='en', dest='ja')
|
| 31 |
if part.thought:
|
|
|
|
|
|
|
|
|
|
| 32 |
summary_thought += translated_text.text
|
| 33 |
else:
|
|
|
|
|
|
|
|
|
|
| 34 |
summary_answer += translated_text.text
|
| 35 |
|
| 36 |
summaries = summary_thought + '\n' + summary_answer
|
| 37 |
+
|
| 38 |
+
return summary_thought,summary_answer
|
| 39 |
|
| 40 |
# Gradio Blocksใฎ่จญๅฎ
|
| 41 |
with gr.Blocks(title="gemini think",css="footer {visibility: hidden;} #header {display: flex; justify-content: space-between; align-items: center; font-size: 24px; font-weight: bold;} #logo {width: 50px; height: 50px;} .logout-btn { background-color: #3498db; border-radius: 10px; color: white; padding: 10px 20px; border: none; cursor: pointer; transparent-bg {background-color: transparent; color: black; padding: 10px; border: none;}") as gemini:
|
|
|
|
| 89 |
''')
|
| 90 |
|
| 91 |
with gr.Row():
|
| 92 |
+
prompt_input = gr.Textbox(label="ใใญใณใใใๅ
ฅๅใใฆใใ ใใ", info="ไพ: ใใๅฎถใฏ่ฒใ
ใชๅ้กใใใพใใใ็ตๆใๅฎขๆฐใๆธใใ็ตๅถไธใๅคงใใชๅ้กใๆตฎไธใใพใใใใใใใๆนๅใใ็ตๅถใๆญฃๅธธๅใใใซใฏใฉใใชๆใกๆใใใใๆใใฆใใ ใใใ")
|
| 93 |
+
output_text = gr.Textbox(label="็ๆใใใThought", info="gemini thinkใง็ๆใใใthoghtใ่กจ็คบใใใพใใ")
|
| 94 |
+
summary_text = gr.Textbox(label="็ตๆ", info="gemini thinkใง็ๆใใใ็ตๆใ่กจ็คบใใใพใใ")
|
| 95 |
|
| 96 |
with gr.Row():
|
| 97 |
generate_button = gr.Button("็ๆ")
|