|
|
|
|
|
from dotenv import load_dotenv
|
|
|
import streamlit as st
|
|
|
import os
|
|
|
import textwrap
|
|
|
import google.generativeai as genai
|
|
|
from IPython.display import Markdown
|
|
|
|
|
|
def to_markdown(text):
|
|
|
text = text.replace('β’', ' *')
|
|
|
return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
|
|
|
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
|
|
|
|
|
|
|
|
|
def get_gemini_response(question):
|
|
|
model = genai.GenerativeModel('gemini-pro')
|
|
|
|
|
|
prompt = f"Answer the following question with respect to the Indian Constitution:\n\n{question}"
|
|
|
response = model.generate_content(prompt)
|
|
|
return response.text
|
|
|
|
|
|
|
|
|
st.set_page_config(page_title="Q&A Demo - Indian Constitution")
|
|
|
|
|
|
st.header("Samvidhan Ko Jaano ππ")
|
|
|
|
|
|
input = st.text_input("Input: ", key="input")
|
|
|
|
|
|
submit = st.button("Ask the question")
|
|
|
|
|
|
|
|
|
if submit:
|
|
|
response = get_gemini_response(input)
|
|
|
st.subheader("The Response is")
|
|
|
st.write(response)
|
|
|
|