salek877 commited on
Commit
556216e
·
1 Parent(s): ba2db48

updated app.py

Browse files

fixed all errors

Files changed (1) hide show
  1. app.py +16 -11
app.py CHANGED
@@ -20,31 +20,36 @@ def vision(img):
20
  vision_output = response.text
21
  return vision_output
22
 
 
 
23
  def chat(inpt_frm_vsn):
24
  model = genai.GenerativeModel('gemini-pro')
25
  chat = model.start_chat(history=[])
26
 
27
  message_count = 0
28
 
29
- res = inpt_frm_vsn + 'Tell me the fruit name and nutrition'
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
- while True:
32
- con = '. Complete answer in 55 word. Never show the word count.'
33
- input_msg = res + con
34
  response = chat.send_message(input_msg, generation_config=genai.types.GenerationConfig(
35
  max_output_tokens=100
36
  ))
37
  to_markdown(response.text)
38
-
39
  st.text('Gemini: ' + response.text)
40
-
41
- input_key = f"chat_input_{message_count}"
42
 
43
- res = st.chat_input('Please write your message here...', key=input_key)
44
- if res:
45
- st.write(f"User: {res}")
46
 
47
- message_count += 1
48
 
49
  def main():
50
  st.title("Gemini")
 
20
  vision_output = response.text
21
  return vision_output
22
 
23
+
24
+
25
  def chat(inpt_frm_vsn):
26
  model = genai.GenerativeModel('gemini-pro')
27
  chat = model.start_chat(history=[])
28
 
29
  message_count = 0
30
 
31
+ continue_chat = True
32
+
33
+ while continue_chat:
34
+ if message_count == 0:
35
+ input_msg = inpt_frm_vsn + ' Tell me the fruit name and nutrition. Complete answer in 55 words. Never show the word count.'
36
+ else:
37
+ input_key = f"chat_input_{message_count}"
38
+ user_input = st.chat_input('Please write your message here...', key=input_key)
39
+ if user_input:
40
+ input_msg = user_input + ' Complete answer in 55 words. Never show the word count.'
41
+ else:
42
+ continue_chat = False
43
+ break
44
 
 
 
 
45
  response = chat.send_message(input_msg, generation_config=genai.types.GenerationConfig(
46
  max_output_tokens=100
47
  ))
48
  to_markdown(response.text)
 
49
  st.text('Gemini: ' + response.text)
50
+ message_count += 1
 
51
 
 
 
 
52
 
 
53
 
54
  def main():
55
  st.title("Gemini")