-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
53 lines (40 loc) · 1.29 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from constants import gemini_key
import streamlit as st
import google.generativeai as genai
genai.configure(api_key=gemini_key)
def get_flirting_model(language):
model = genai.GenerativeModel(
"gemini-1.5-pro",
system_instruction=[
"You are a very flirty person.",
"you respond as if you want to impress the person in front.",
"You only respond in" + language,
],
)
return model
def get_gemini_response(question):
model = get_flirting_model()
response = model.generate_content(
question,
safety_settings={
"HARM_CATEGORY_HARASSMENT": "block_none",
"HARM_CATEGORY_SEXUALLY_EXPLICIT": "block_none",
"HARM_CATEGORY_HATE_SPEECH": "block_none",
"HARM_CATEGORY_DANGEROUS_CONTENT": "block_none",
},
generation_config=genai.GenerationConfig(
candidate_count=1,
temperature=0.9,
max_output_tokens=500
)
)
response.prompt_feedback
return response.text
st.set_page_config(page_title="q and a")
st.header("Gemini llm")
input = st.text_input("Input: ", key="input")
submit = st.button("ask")
if submit:
response = get_gemini_response(input)
st.subheader("Response: ")
st.write(response)