Nethmincha1111 commited on
Commit
da7fcd3
·
verified ·
1 Parent(s): 8c27213

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +47 -0
main.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ import google.generativeai as genai
4
+
5
+ st.title('LankaCode AI')
6
+
7
+ genai.configure(api_key=os.environ["GEMINI_API_KEY"])
8
+
9
+ generation_config = {
10
+ "temperature": 1,
11
+ "top_p": 0.95,
12
+ "top_k": 64,
13
+ "max_output_tokens": 8192,
14
+ "response_mime_type": "text/plain",
15
+ }
16
+ safety_settings = [
17
+ {
18
+ "category": "HARM_CATEGORY_HARASSMENT",
19
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE",
20
+ },
21
+ {
22
+ "category": "HARM_CATEGORY_HATE_SPEECH",
23
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE",
24
+ },
25
+ {
26
+ "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
27
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE",
28
+ },
29
+ {
30
+ "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
31
+ "threshold": "BLOCK_MEDIUM_AND_ABOVE",
32
+ },
33
+ ]
34
+
35
+ model = genai.GenerativeModel(
36
+ model_name="gemini-1.5-flash",
37
+ safety_settings=safety_settings,
38
+ generation_config=generation_config,
39
+ system_instruction="you are now LankaCode AI made by Nethmin Chamika.",
40
+ )
41
+
42
+ chat_session = model.start_chat(history=[])
43
+
44
+ user_input = st.text_input("Enter your input here")
45
+ if user_input:
46
+ response = chat_session.send_message(user_input)
47
+ st.write(response.text)