Spaces:
Runtime error
Runtime error
File size: 1,003 Bytes
44afdce b3edc96 44afdce |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import os
import google.generativeai as genai
import gradio as gr
# Configure the Gemini API
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
# Define the model with a placeholder for system instruction
def generate_text(system_instruction, prompt):
model = genai.GenerativeModel(
model_name="gemini-1.5-flash",
system_instruction=system_instruction
)
chat_session = model.start_chat(history=[])
response = chat_session.send_message(prompt)
return response.text
# Gradio interface
iface = gr.Interface(
fn=generate_text,
inputs=[
gr.Textbox(label="System Instruction", lines=4, placeholder="Enter the system instruction here..."),
gr.Textbox(label="Prompt", lines=4, placeholder="Enter the prompt here...")
],
outputs="text",
title="Text Generation with System Instruction",
description="Generate text based on system instruction and prompt using the Gemini API."
)
if __name__ == "__main__":
iface.launch()
|