Mr-Vicky-01 commited on
Commit
3394c04
1 Parent(s): aa7d22d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import google.generativeai as genai
3
+ import os
4
+
5
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
6
+
7
+ model = genai.GenerativeModel("gemini-1.5-pro-latest")
8
+ prompt = """
9
+ Input Text: {tamil_text} (Tanglish)
10
+
11
+ Task:
12
+
13
+ 1. Translate the input text to English.
14
+ 2. Identify and explain grammatical errors.
15
+ 3. Explain word choice and provide synonyms.
16
+
17
+ give me the output in this format:
18
+
19
+ 1. English Translation: The user input translated into grammatically correct English.
20
+ 2. Grammar Explanation: A clear explanation of any grammatical errors in the user input (Tanglish) and suggestions for correction in Tamil.
21
+ 3. Word Choice Explanation and Synonyms: Explanation of vocabulary meaning and synonyms in both English and Tamil.
22
+ """
23
+
24
+ def generate_response(input_text):
25
+ query = prompt.format(tamil_text=input_text)
26
+ response = model.generate_content(query)
27
+ response = response.text
28
+ return st.markdown(response)
29
+
30
+ st.title("English Teaching AI")
31
+ user_query = st.text_area("Type Tamil or Tanglish sentance")
32
+ submit = st.button("Analyze")
33
+ if submit:
34
+ with st.spinner("Processing..."):
35
+ generate_response(user_query)