AliZain1 commited on
Commit
06d2c0d
·
verified ·
1 Parent(s): 29d435f

Update app.py

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