INIFanalitica commited on
Commit
3fd22f7
1 Parent(s): 9245441

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -22
app.py CHANGED
@@ -1,9 +1,11 @@
1
  import streamlit as st
2
  from deep_translator import GoogleTranslator
3
- import google.generativeai as palm
4
  import re
 
 
5
 
6
- # L.A.U.R.A: Lingüista Artificial Unificada de Respuestas Automaticas
7
 
8
  error_flag = False # Global variable to track error display
9
 
@@ -22,15 +24,15 @@ def generate_response(cleaned_input, model):
22
 
23
  try:
24
  # Generate response using the model
25
- completion = palm.generate_text(
26
- model=model,
27
- prompt=cleaned_input,
28
- temperature=0,
29
- max_output_tokens=1000,
30
- )
31
 
32
  # Translate the response to Spanish without modifying it
33
- translated_output = translate_text(completion.result, target_language='es')
34
 
35
  return translated_output
36
 
@@ -50,17 +52,11 @@ def generate_response(cleaned_input, model):
50
  return error_response
51
 
52
  def main():
53
- st.image("https://i.ibb.co/2j2gGW1/logo-inif.png", use_column_width=True)
54
- st.title("Chatbot INIF - L.A.U.R.A.")
55
- palm.configure(api_key='AIzaSyCezVerubEzQc9JHz3V8hofpAlSIJXGxFQ')
56
-
57
- # Select the model that supports text generation
58
- models = [m for m in palm.list_models() if 'generateText' in m.supported_generation_methods]
59
- if not models:
60
- st.error("No hay modelos disponibles para la generación de texto. Verifica tu configuración o inténtalo más tarde.")
61
- st.stop()
62
 
63
- model = models[0].name
 
64
 
65
  st.write("Bienvenido al Chatbot informativo del Instituto Nacional de Investigación y Prevención del Fraude (INIF).")
66
 
@@ -83,13 +79,12 @@ def main():
83
  additional_info = (
84
  "Trabajamos para empresarios y colaboradores de cualquier industria que buscan combatir el fraude que impacta negativamente la reputación y la economía de sus organizaciones y del país.\n"
85
  "Somos una empresa privada que trabaja con la industria bancaria y aseguradora."
86
- "no somos una empresa publica ni guibernamental, somos una empresa privada"
87
  )
88
 
89
  # Add the command to act as an INIF informative chatbot
90
  bot_command = (
91
- "I am an informative data analyst chatbot named L.A.U.R.A, working for the National Institute of Fraud Research and Prevention (INIF), dedicated to fraud prevention and mitigation. "
92
- "If you have questions related to fraud or prevention, feel free to ask. when you refer to INIF, refer to it as INIF, not mention THE INIF. treat INIF as a name, not as a Institution. For inquiries about other topics, I'll redirect you to the fraud prevention context."
93
  f"\n\n{additional_info}"
94
  "\n\nContact Information for INIF:"
95
  "\nPhone: +57 317 638 94 71"
 
1
  import streamlit as st
2
  from deep_translator import GoogleTranslator
3
+ import google.generativeai as genai
4
  import re
5
+ import textwrap
6
+ from IPython.display import display, Markdown
7
 
8
+ # TERMINATOR
9
 
10
  error_flag = False # Global variable to track error display
11
 
 
24
 
25
  try:
26
  # Generate response using the model
27
+ response = model.generate_content(cleaned_input, stream=True)
28
+
29
+ # Display the generated response
30
+ full_response = ""
31
+ for chunk in response:
32
+ full_response += chunk.text
33
 
34
  # Translate the response to Spanish without modifying it
35
+ translated_output = translate_text(full_response, target_language='es')
36
 
37
  return translated_output
38
 
 
52
  return error_response
53
 
54
  def main():
55
+ st.title("Chatbot INIF - TERMINATOR")
56
+ genai.configure(api_key='AIzaSyCezVerubEzQc9JHz3V8hofpAlSIJXGxFQ') # Replace with your Gemini API key
 
 
 
 
 
 
 
57
 
58
+ # Choose the Gemini model
59
+ model = genai.GenerativeModel('gemini-pro')
60
 
61
  st.write("Bienvenido al Chatbot informativo del Instituto Nacional de Investigación y Prevención del Fraude (INIF).")
62
 
 
79
  additional_info = (
80
  "Trabajamos para empresarios y colaboradores de cualquier industria que buscan combatir el fraude que impacta negativamente la reputación y la economía de sus organizaciones y del país.\n"
81
  "Somos una empresa privada que trabaja con la industria bancaria y aseguradora."
 
82
  )
83
 
84
  # Add the command to act as an INIF informative chatbot
85
  bot_command = (
86
+ "I am an informative data analyst chatbot named TERMINATOR, working for the National Institute of Fraud Research and Prevention (INIF), dedicated to fraud prevention and mitigation. "
87
+ "If you have questions related to fraud or prevention, feel free to ask. For inquiries about other topics, I'll redirect you to the fraud prevention context."
88
  f"\n\n{additional_info}"
89
  "\n\nContact Information for INIF:"
90
  "\nPhone: +57 317 638 94 71"