Pezh commited on
Commit
a2996e0
·
1 Parent(s): 4d762e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -3
app.py CHANGED
@@ -1,5 +1,44 @@
1
  import streamlit as st
2
  from PIL import Image
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # Set up the title of the app
5
  st.title('Simple Streamlit App')
@@ -14,13 +53,13 @@ if uploaded_file is not None:
14
 
15
  # Button to print "Hey you"
16
  if st.button('Hey Button'):
17
- st.write('Hey you')
18
 
19
  # Text input
20
- text_input = st.text_input('Enter some text')
21
 
22
  # Button to print the text from input
23
  if st.button('Print Text'):
24
- st.write(text_input)
25
 
26
  # Run this with `streamlit run your_script.py`
 
1
  import streamlit as st
2
  from PIL import Image
3
+ import google.generativeai as genai
4
+
5
+ genai.configure(api_key="AIzaSyBd36RWeqDpLur3E7TTlX3wnyIh_rdhsU8")
6
+
7
+ # Set up the model
8
+ generation_config = {
9
+ "temperature": 0.9,
10
+ "top_p": 1,
11
+ "top_k": 1,
12
+ "max_output_tokens": 2048,
13
+ }
14
+
15
+ safety_settings = [
16
+ {
17
+ "category": "HARM_CATEGORY_HARASSMENT",
18
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
19
+ },
20
+ {
21
+ "category": "HARM_CATEGORY_HATE_SPEECH",
22
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
23
+ },
24
+ {
25
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
26
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
27
+ },
28
+ {
29
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
30
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE"
31
+ },
32
+ ]
33
+ text_input = st.text_input('Enter some text')
34
+
35
+ model = genai.GenerativeModel(model_name="gemini-pro",
36
+ generation_config=generation_config,
37
+ safety_settings=safety_settings)
38
+
39
+ prompt_parts = [text_input]
40
+
41
+ response = model.generate_content(prompt_parts)
42
 
43
  # Set up the title of the app
44
  st.title('Simple Streamlit App')
 
53
 
54
  # Button to print "Hey you"
55
  if st.button('Hey Button'):
56
+ st.write('Hey koskhol!')
57
 
58
  # Text input
59
+ #text_input = st.text_input('Enter some text')
60
 
61
  # Button to print the text from input
62
  if st.button('Print Text'):
63
+ st.write(response.text)
64
 
65
  # Run this with `streamlit run your_script.py`