Manikandan-Alagu commited on
Commit
7a2aaa0
·
verified ·
1 Parent(s): 75e9e3d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -27
app.py CHANGED
@@ -1,35 +1,43 @@
1
 
2
  import os
3
  import gradio as gr
4
-
5
  import google.generativeai as genai
6
 
7
  GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY", None)
8
  genai.configure(api_key=GEMINI_API_KEY)
9
 
10
- # Create the model
11
- generation_config = {
12
- "temperature": 1,
13
- "top_p": 0.95,
14
- "top_k": 64,
15
- "max_output_tokens": 8192,
16
- "response_mime_type": "text/plain",
17
- }
18
-
19
- model = genai.GenerativeModel(
20
- model_name="gemini-1.5-flash",
21
- generation_config=generation_config,
22
- # safety_settings = Adjust safety settings
23
- # See https://ai.google.dev/gemini-api/docs/safety-settings
24
- system_instruction="give the response in friendly tone",
25
- )
26
-
27
- chat_session = model.start_chat(
28
- history=[
29
-
30
- ]
31
- )
32
-
33
- response = chat_session.send_message("INSERT_INPUT_HERE")
34
-
35
- print(response.text)
 
 
 
 
 
 
 
 
 
 
1
 
2
  import os
3
  import gradio as gr
 
4
  import google.generativeai as genai
5
 
6
  GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY", None)
7
  genai.configure(api_key=GEMINI_API_KEY)
8
 
9
+ def model(input):
10
+
11
+ # Create the model
12
+ generation_config = {
13
+ "temperature": 1,
14
+ "top_p": 0.95,
15
+ "top_k": 64,
16
+ "max_output_tokens": 8192,
17
+ "response_mime_type": "text/plain",
18
+ }
19
+
20
+ model = genai.GenerativeModel(
21
+ model_name="gemini-1.5-flash",
22
+ generation_config=generation_config,
23
+ # safety_settings = Adjust safety settings
24
+ # See https://ai.google.dev/gemini-api/docs/safety-settings
25
+ system_instruction="give the response in friendly tone",
26
+ )
27
+
28
+ chat_session = model.start_chat(
29
+ history=[
30
+
31
+ ]
32
+ )
33
+
34
+ response = chat_session.send_message(input)
35
+
36
+ return response.text
37
+
38
+
39
+
40
+ demo = gr.Interface(fn=model, inputs="textbox", outputs="textbox")
41
+
42
+ if __name__ == "__main__":
43
+ demo.launch()