INIFanalitica
commited on
Commit
•
3fd22f7
1
Parent(s):
9245441
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,11 @@
|
|
1 |
import streamlit as st
|
2 |
from deep_translator import GoogleTranslator
|
3 |
-
import google.generativeai as
|
4 |
import re
|
|
|
|
|
5 |
|
6 |
-
#
|
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 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
# Translate the response to Spanish without modifying it
|
33 |
-
translated_output = translate_text(
|
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.
|
54 |
-
|
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 |
-
|
|
|
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
|
92 |
-
"If you have questions related to fraud or prevention, feel free to ask.
|
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"
|