Spaces:
Running
Running
import streamlit as st | |
import google.generativeai as genai | |
import os | |
genai.configure(api_key=os.getenv("GOOGLE_API_KEY")) | |
model = genai.GenerativeModel("gemini-1.5-pro-latest") | |
prompt = """ | |
Input Text: {tamil_text} (Tanglish) | |
Task: | |
1. Translate the input text to English. | |
2. Identify and explain grammatical errors. | |
3. Explain word choice and provide synonyms. | |
give me the output in this format: | |
1. English Translation: The user input translated into grammatically correct English. | |
2. Grammar Explanation: A clear explanation of any grammatical errors in the user input (Tanglish) and suggestions for correction in Tamil. | |
3. Word Choice Explanation and Synonyms: Explanation of vocabulary meaning and synonyms in both English and Tamil. | |
""" | |
def generate_response(input_text): | |
query = prompt.format(tamil_text=input_text) | |
response = model.generate_content(query) | |
response = response.text | |
return st.markdown(response) | |
st.title("English Teaching AI") | |
user_query = st.text_area("Type Tamil or Tanglish sentance") | |
submit = st.button("Analyze") | |
if submit: | |
with st.spinner("Processing..."): | |
generate_response(user_query) |