Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| import google.generativeai as genai | |
| def generate_chat(api_key, prompt_parts): | |
| genai.configure(api_key=api_key) | |
| model = genai.GenerativeModel(model_name="gemini-pro") | |
| response = model.generate_content([prompt_parts]) | |
| return response.text | |
| with gr.Blocks() as app: | |
| gr.Markdown("# gemini-pro generate_chat demo") | |
| gr.Markdown("This is just a very simple demo,Enter your API key to start the conversation. Get a free API key from here: https://ai.google.dev/") | |
| api_key_input = gr.Textbox(label="API Key", type="password", placeholder="Enter your API key", lines=1) | |
| prompt_input = gr.Textbox(label="Prompt", placeholder="Enter your Prompt", lines=3) | |
| generate_button = gr.Button("Generate Content") | |
| output = gr.Markdown() | |
| generate_button.click( | |
| generate_chat, | |
| inputs=[api_key_input, prompt_input], | |
| outputs=output | |
| ) | |
| app.launch() | |