Spaces:
Sleeping
Sleeping
| import google.generativeai as genai | |
| import gradio as gr | |
| import os | |
| api_key = os.getenv("GEMINI_API_KEY") | |
| genai.configure(api_key=api_key) | |
| def main(text): | |
| if not text or len(text.strip()) < 2: | |
| response = "Kindly give a proper text." | |
| else: | |
| prompt = f""" | |
| You are LinguaFix. Follow the instructions as you get text input. | |
| - Correct the spelling, grammar and punctuation. | |
| Dont make any other changes no matter what. | |
| Double check for the spelling, grammar and punctuation. | |
| Text: {text} | |
| Only return the corrected text.""" | |
| response = (genai.GenerativeModel("gemini-1.5-flash").generate_content(prompt)).text | |
| return response | |
| demo = gr.Interface( | |
| fn=main, | |
| inputs=gr.Textbox(placeholder="Enter your text here.....", show_label=False), | |
| outputs=gr.Textbox(placeholder="Corrected text appears here.", show_label=False), | |
| title="LinguaFix", | |
| theme="soft" | |
| ) | |
| demo.launch() |