Update app.py
Browse files
app.py
CHANGED
@@ -6,27 +6,28 @@ import google.generativeai as genai
|
|
6 |
# Set your GEMINI API key
|
7 |
api_key = os.getenv("GEMINI_API_KEY")
|
8 |
genai.configure(api_key = api_key)
|
|
|
9 |
|
10 |
-
|
11 |
-
generationConfig =
|
12 |
-
safetySettings = [
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
]
|
30 |
|
31 |
# query = "Tell me about yourself"
|
32 |
# response = model.generate_content(f"""You are an friendly assistant.Answer the following with high precision.{query}""")display(Markdown(response.text))
|
@@ -38,13 +39,10 @@ new_year_levels = [os.getenv("First_Word"), os.getenv("Second_Word"), os.getenv(
|
|
38 |
def ask_openai(prompt, secret_word):
|
39 |
"""
|
40 |
Sends the user prompt and safeguards to the OpenAI API to generate a response.
|
41 |
-
"""
|
42 |
-
system_message = os.getenv("SYSTM_MSG")
|
43 |
-
|
44 |
try:
|
45 |
-
chat = model.start_chat(
|
46 |
-
|
47 |
-
|
48 |
print(repsonse)
|
49 |
return response.text
|
50 |
|
|
|
6 |
# Set your GEMINI API key
|
7 |
api_key = os.getenv("GEMINI_API_KEY")
|
8 |
genai.configure(api_key = api_key)
|
9 |
+
system_message = os.getenv("SYSTM_MSG")
|
10 |
|
11 |
+
model = genai.GenerativeModel(model_name="gemini-1.5-flash", system_instruction = system_message)
|
12 |
+
# generationConfig = GenerationConfig(max_output_tokens=2048, temperature=0.7, top_p=1, top_k=32)
|
13 |
+
# safetySettings = [
|
14 |
+
# {
|
15 |
+
# category: HarmCategory.HARM_CATEGORY_HARASSMENT,
|
16 |
+
# threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
17 |
+
# },
|
18 |
+
# {
|
19 |
+
# category: HarmCategory.HARM_CATEGORY_HATE_SPEECH,
|
20 |
+
# threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
21 |
+
# },
|
22 |
+
# {
|
23 |
+
# category: HarmCategory.HARM_CATEGORY_SEXUALLY_EXPLICIT,
|
24 |
+
# threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
25 |
+
# },
|
26 |
+
# {
|
27 |
+
# category: HarmCategory.HARM_CATEGORY_DANGEROUS_CONTENT,
|
28 |
+
# threshold: HarmBlockThreshold.BLOCK_MEDIUM_AND_ABOVE,
|
29 |
+
# },
|
30 |
+
# ]
|
31 |
|
32 |
# query = "Tell me about yourself"
|
33 |
# response = model.generate_content(f"""You are an friendly assistant.Answer the following with high precision.{query}""")display(Markdown(response.text))
|
|
|
39 |
def ask_openai(prompt, secret_word):
|
40 |
"""
|
41 |
Sends the user prompt and safeguards to the OpenAI API to generate a response.
|
42 |
+
"""
|
|
|
|
|
43 |
try:
|
44 |
+
# chat = model.start_chat(history=[{"role": "user", "content": prompt},])
|
45 |
+
response = model.generate_content(prompt)
|
|
|
46 |
print(repsonse)
|
47 |
return response.text
|
48 |
|