hide openai key
Browse files- app.py +1 -2
- config.py +11 -2
- src/view/view.py +4 -7
app.py
CHANGED
@@ -10,7 +10,6 @@ from src.tools.llm import LlmAgent
|
|
10 |
from src.model.doc import Doc
|
11 |
import src.view.view as view
|
12 |
|
13 |
-
os.environ["OPENAI_API_KEY"] = OpenAI_KEY
|
14 |
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
15 |
|
16 |
doc_content = Doc(content_en_path)
|
@@ -28,6 +27,6 @@ specials['accommodation_meal_df'] = pd.read_csv(specials['accommodation_meal_pat
|
|
28 |
controller = Controller(retriever=retriever, llm=llm, content_language=content_language, plan_language=plan_language,
|
29 |
specials=specials)
|
30 |
|
31 |
-
qna = view.run(ctrl=controller,
|
32 |
|
33 |
qna.queue().launch()
|
|
|
10 |
from src.model.doc import Doc
|
11 |
import src.view.view as view
|
12 |
|
|
|
13 |
os.environ["TOKENIZERS_PARALLELISM"] = "true"
|
14 |
|
15 |
doc_content = Doc(content_en_path)
|
|
|
27 |
controller = Controller(retriever=retriever, llm=llm, content_language=content_language, plan_language=plan_language,
|
28 |
specials=specials)
|
29 |
|
30 |
+
qna = view.run(ctrl=controller, config=view_config)
|
31 |
|
32 |
qna.queue().launch()
|
config.py
CHANGED
@@ -5,7 +5,9 @@ content_en_path = 'data/business_trips_content_until_end_en.docx'
|
|
5 |
content_fr_path = 'data/business_trips_content_until_end_fr.docx'
|
6 |
|
7 |
collection_name = "until_end"
|
8 |
-
|
|
|
|
|
9 |
examples = {
|
10 |
"Remboursement de frais de voiture": "Comment sont remboursés mes frais kilométriques sur mes trajets "
|
11 |
"professionnels?",
|
@@ -15,11 +17,18 @@ examples = {
|
|
15 |
"Indemnités pour des séjours longs en Bolivie": "Y a-t-il des indemnités pour des séjours longs en Bolivie?",
|
16 |
"Indemnités pour les repas aux Pays-Bas": "Quelles sont les indemnités pour les repas au Pays-Bas?"
|
17 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
countries_extensions = {
|
19 |
'Royaume-Uni': ['UK', 'U.K.','RU', 'R.U.', 'Angleterre'],
|
20 |
'Etats-Unis': ['Etats-unis', 'Etats Unis', 'Etats unis', 'ETATS-UNIS', 'USA'],
|
21 |
'E.A.U': ["EAU", "Emirats", "Emirats Arabes Unis", "Emirates", "UAE", "United Arab Emirates"],
|
22 |
-
'Pays-Bas': ['Les Pays-Bas']
|
23 |
}
|
24 |
specials = {'remote_rate_path': 'data/remote_rates.csv',
|
25 |
'remote_rate_known': "the scale rate of remoteness for the ",
|
|
|
5 |
content_fr_path = 'data/business_trips_content_until_end_fr.docx'
|
6 |
|
7 |
collection_name = "until_end"
|
8 |
+
|
9 |
+
|
10 |
+
|
11 |
examples = {
|
12 |
"Remboursement de frais de voiture": "Comment sont remboursés mes frais kilométriques sur mes trajets "
|
13 |
"professionnels?",
|
|
|
17 |
"Indemnités pour des séjours longs en Bolivie": "Y a-t-il des indemnités pour des séjours longs en Bolivie?",
|
18 |
"Indemnités pour les repas aux Pays-Bas": "Quelles sont les indemnités pour les repas au Pays-Bas?"
|
19 |
}
|
20 |
+
|
21 |
+
|
22 |
+
view_config = {
|
23 |
+
'title': '# Questions sur la politique "Voyages et Déplacements" de la RCompany',
|
24 |
+
'examples': examples,
|
25 |
+
|
26 |
+
}
|
27 |
countries_extensions = {
|
28 |
'Royaume-Uni': ['UK', 'U.K.','RU', 'R.U.', 'Angleterre'],
|
29 |
'Etats-Unis': ['Etats-unis', 'Etats Unis', 'Etats unis', 'ETATS-UNIS', 'USA'],
|
30 |
'E.A.U': ["EAU", "Emirats", "Emirats Arabes Unis", "Emirates", "UAE", "United Arab Emirates"],
|
31 |
+
'Pays-Bas': ['Les Pays-Bas', 'Hollande', 'Holland']
|
32 |
}
|
33 |
specials = {'remote_rate_path': 'data/remote_rates.csv',
|
34 |
'remote_rate_known': "the scale rate of remoteness for the ",
|
src/view/view.py
CHANGED
@@ -2,18 +2,15 @@ import gradio as gr
|
|
2 |
from src.control.control import Controller
|
3 |
|
4 |
|
5 |
-
def run(ctrl: Controller,
|
6 |
with gr.Blocks() as qna:
|
7 |
with gr.Row():
|
8 |
with gr.Column():
|
9 |
pass
|
10 |
|
11 |
with gr.Column(scale=10):
|
12 |
-
"""
|
13 |
-
1. input docs components
|
14 |
-
"""
|
15 |
|
16 |
-
gr.Markdown(
|
17 |
|
18 |
input_text_comp = gr.Textbox(
|
19 |
label="",
|
@@ -24,7 +21,7 @@ def run(ctrl: Controller, examples: {}):
|
|
24 |
)
|
25 |
input_example_comp = gr.Radio(
|
26 |
label="Examples de questions",
|
27 |
-
choices=list(examples.keys()),
|
28 |
)
|
29 |
output_text_comp = gr.Textbox(
|
30 |
label="La réponse automatique",
|
@@ -59,7 +56,7 @@ def run(ctrl: Controller, examples: {}):
|
|
59 |
|
60 |
def input_example_fn(input_example_):
|
61 |
update_ = {
|
62 |
-
input_text_comp: gr.update(value=examples[input_example_]),
|
63 |
output_text_comp: gr.update(visible=True),
|
64 |
}
|
65 |
return update_
|
|
|
2 |
from src.control.control import Controller
|
3 |
|
4 |
|
5 |
+
def run(ctrl: Controller, config: {}):
|
6 |
with gr.Blocks() as qna:
|
7 |
with gr.Row():
|
8 |
with gr.Column():
|
9 |
pass
|
10 |
|
11 |
with gr.Column(scale=10):
|
|
|
|
|
|
|
12 |
|
13 |
+
gr.Markdown(config['title'])
|
14 |
|
15 |
input_text_comp = gr.Textbox(
|
16 |
label="",
|
|
|
21 |
)
|
22 |
input_example_comp = gr.Radio(
|
23 |
label="Examples de questions",
|
24 |
+
choices=list(config['examples'].keys()),
|
25 |
)
|
26 |
output_text_comp = gr.Textbox(
|
27 |
label="La réponse automatique",
|
|
|
56 |
|
57 |
def input_example_fn(input_example_):
|
58 |
update_ = {
|
59 |
+
input_text_comp: gr.update(value=config['examples'][input_example_]),
|
60 |
output_text_comp: gr.update(visible=True),
|
61 |
}
|
62 |
return update_
|