lalashechka commited on
Commit
4ab4257
1 Parent(s): 52a1c89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -2,11 +2,9 @@ import google.generativeai as genai
2
  import gradio as gr
3
 
4
 
5
- def flip_text(prompt):
6
  def init_api_keys():
7
  try:
8
-
9
- api_key = 'AIzaSyBYxPTwLyP7D6Hiyydk3olQ1FeXoP78wmc'
10
  genai.configure(api_key=api_key)
11
  except Exception as exception:
12
  print("Error in initializing API keys:", exception)
@@ -16,10 +14,10 @@ def flip_text(prompt):
16
  def generate_response(prompt: str):
17
  # Set up the model
18
  generation_config = {
19
- "temperature": 0.1,
20
  "top_p": 1,
21
  "top_k": 1,
22
- "max_output_tokens": 2048,
23
  }
24
 
25
  model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest", generation_config=generation_config)
@@ -45,11 +43,13 @@ with gr.Blocks() as demo:
45
  with gr.Tab("Базовые настройки"):
46
  with gr.Row():
47
  prompt = gr.Textbox(placeholder="Введите описание...", show_label=True, label='Описание:', lines=3)
 
 
48
 
49
  with gr.Column():
50
  text_button = gr.Button("Сгенерировать текст", variant='primary', elem_id="generate")
51
  with gr.Column():
52
  image_output = gr.Textbox(lines=30, elem_id='image_output')
53
- text_button.click(flip_text, inputs=[prompt], outputs=image_output, concurrency_limit=48)
54
 
55
  demo.launch()
 
2
  import gradio as gr
3
 
4
 
5
+ def flip_text(prompt, api_key):
6
  def init_api_keys():
7
  try:
 
 
8
  genai.configure(api_key=api_key)
9
  except Exception as exception:
10
  print("Error in initializing API keys:", exception)
 
14
  def generate_response(prompt: str):
15
  # Set up the model
16
  generation_config = {
17
+ "temperature": 1,
18
  "top_p": 1,
19
  "top_k": 1,
20
+ "max_output_tokens": 8192,
21
  }
22
 
23
  model = genai.GenerativeModel(model_name="gemini-1.5-pro-latest", generation_config=generation_config)
 
43
  with gr.Tab("Базовые настройки"):
44
  with gr.Row():
45
  prompt = gr.Textbox(placeholder="Введите описание...", show_label=True, label='Описание:', lines=3)
46
+ with gr.Row():
47
+ api_key = gr.Textbox(placeholder="Введите api_key...", show_label=True, label='Описание:', lines=3)
48
 
49
  with gr.Column():
50
  text_button = gr.Button("Сгенерировать текст", variant='primary', elem_id="generate")
51
  with gr.Column():
52
  image_output = gr.Textbox(lines=30, elem_id='image_output')
53
+ text_button.click(flip_text, inputs=[prompt, api_key], outputs=image_output, concurrency_limit=48)
54
 
55
  demo.launch()