ASG Models commited on
Commit
4835adc
1 Parent(s): a4b3ad4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -15,7 +15,7 @@ generation_config = {
15
  }
16
 
17
  model = genai.GenerativeModel(
18
- model_name="gemini-1.5-pro",
19
  generation_config=generation_config,
20
  # safety_settings = Adjust safety settings
21
  # See https://ai.google.dev/gemini-api/docs/safety-settings
@@ -71,17 +71,19 @@ AI=create_chat_session()
71
  def get_answer_ai(text):
72
  global AI
73
  try:
74
- response = AI.send_message(text)
75
- return response.text
76
 
77
 
78
  except :
79
  AI=create_chat_session()
80
- response = AI.send_message(text)
81
- return response.text
82
  def dash(text):
83
- textai=get_answer_ai(text)
84
- return textai
 
 
85
 
86
  demo = gr.Interface(fn=dash, inputs="text", outputs="text")
87
  demo.launch()
 
15
  }
16
 
17
  model = genai.GenerativeModel(
18
+ model_name="gemini-1.5-flash",
19
  generation_config=generation_config,
20
  # safety_settings = Adjust safety settings
21
  # See https://ai.google.dev/gemini-api/docs/safety-settings
 
71
  def get_answer_ai(text):
72
  global AI
73
  try:
74
+ response = AI.send_message(text,stream=True)
75
+ return response
76
 
77
 
78
  except :
79
  AI=create_chat_session()
80
+ response = AI.send_message(text,stream=True)
81
+ return response
82
  def dash(text):
83
+ response=get_answer_ai(text)
84
+ for chunk in response:
85
+ yield chunk.text
86
+ # return textai
87
 
88
  demo = gr.Interface(fn=dash, inputs="text", outputs="text")
89
  demo.launch()