AliZain1 commited on
Commit
29d435f
·
verified ·
1 Parent(s): 1977b0b

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +47 -0
  2. requirements.txt +5 -0
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Q&A Chatbot
2
+
3
+ import streamlit as st
4
+ import os
5
+ import pathlib
6
+ import textwrap
7
+ from langchain_google_genai import ChatGoogleGenerativeAI
8
+ import google.generativeai as genai
9
+ from constant import GOOGLE_API_KEY
10
+
11
+ from IPython.display import display
12
+ from IPython.display import Markdown
13
+
14
+
15
+ def to_markdown(text):
16
+ text = text.replace('•', ' *')
17
+ return Markdown(textwrap.indent(text, '> ', predicate=lambda _: True))
18
+
19
+ # os.getenv("GOOGLE_API_KEY")
20
+ # genai.configure(api_key=GOOGLE_API_KEY)
21
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
22
+
23
+ ## Function to load OpenAI model and get respones
24
+
25
+ def get_gemini_response(question):
26
+ model = genai.GenerativeModel('gemini-pro')
27
+ response = model.generate_content(question)
28
+ return response.text
29
+
30
+ ##initialize our streamlit app
31
+
32
+ st.set_page_config(page_title="Q&A Demo")
33
+
34
+ st.header("Gemini Application Made By Computer Program")
35
+
36
+ input=st.text_input("Input: ",key="input")
37
+
38
+
39
+ submit=st.button("Ask the question")
40
+
41
+ ## If ask button is clicked
42
+
43
+ if submit:
44
+
45
+ response=get_gemini_response(input)
46
+ st.subheader("The Response is")
47
+ st.write(response)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit
2
+ google-generativeai
3
+ python-dotenv
4
+ langchain-google-genai
5
+ IPython