Spaces:
Sleeping
Sleeping
update default public config
Browse files- app.py +14 -3
- spinoza_project/config_public.yaml +0 -3
- spinoza_project/source/frontend/gradio_utils.py +18 -2
app.py
CHANGED
@@ -19,6 +19,7 @@ from spinoza_project.source.frontend.gradio_utils import (
|
|
19 |
get_init_prompt,
|
20 |
get_synthesis_prompt,
|
21 |
get_qdrants,
|
|
|
22 |
start_agents,
|
23 |
end_agents,
|
24 |
next_call,
|
@@ -50,11 +51,17 @@ llm = get_llm_api()
|
|
50 |
|
51 |
## Loading BDDs
|
52 |
print("Loading Databases")
|
53 |
-
|
|
|
|
|
54 |
bdd_presse = get_vectorstore_api("presse")
|
55 |
bdd_afp = get_vectorstore_api("afp")
|
56 |
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
|
59 |
## Loading Assets
|
60 |
css, source_information = get_assets()
|
@@ -79,7 +86,11 @@ def reformulate_questions(
|
|
79 |
|
80 |
|
81 |
def retrieve_sources(
|
82 |
-
*questions,
|
|
|
|
|
|
|
|
|
83 |
):
|
84 |
formated_sources, text_sources = get_sources(
|
85 |
questions, qdrants, bdd_presse, bdd_afp, config
|
|
|
19 |
get_init_prompt,
|
20 |
get_synthesis_prompt,
|
21 |
get_qdrants,
|
22 |
+
get_qdrants_public,
|
23 |
start_agents,
|
24 |
end_agents,
|
25 |
next_call,
|
|
|
51 |
|
52 |
## Loading BDDs
|
53 |
print("Loading Databases")
|
54 |
+
qdrants = get_qdrants(config)
|
55 |
+
|
56 |
+
if os.getenv("EKI_OPENAI_LLM_DEPLOYMENT_NAME"):
|
57 |
bdd_presse = get_vectorstore_api("presse")
|
58 |
bdd_afp = get_vectorstore_api("afp")
|
59 |
|
60 |
+
else:
|
61 |
+
qdrants_public = get_qdrants_public(config, "momenaca/hackathon_spinoza")
|
62 |
+
qdrants = {**qdrants, **qdrants_public}
|
63 |
+
bdd_presse = None
|
64 |
+
bdd_afp = None
|
65 |
|
66 |
## Loading Assets
|
67 |
css, source_information = get_assets()
|
|
|
86 |
|
87 |
|
88 |
def retrieve_sources(
|
89 |
+
*questions,
|
90 |
+
qdrants=qdrants,
|
91 |
+
bdd_presse=bdd_presse,
|
92 |
+
bdd_afp=bdd_afp,
|
93 |
+
config=config,
|
94 |
):
|
95 |
formated_sources, text_sources = get_sources(
|
96 |
questions, qdrants, bdd_presse, bdd_afp, config
|
spinoza_project/config_public.yaml
CHANGED
@@ -10,14 +10,12 @@ tabs:
|
|
10 |
* *Des études et recherches sur des impacts locaux*\n
|
11 |
* *Des documents institutionnels (analyses demandées par la France & rapports d'activité)*\n
|
12 |
* *Les plans de transition sectoriels pour les secteurs industriels les plus émetteurs : (verre, papier, ciment, acier, aluminium, chimie, sucre)*"
|
13 |
-
Hackathon: "*Créez votre propre agent personnalisé.*"
|
14 |
|
15 |
source_mapping:
|
16 |
GIEC et IPBES: "Science"
|
17 |
Textes Juridiques: "Loi"
|
18 |
Organismes publics: "Organismes publics"
|
19 |
ADEME: "ADEME"
|
20 |
-
Hackathon: "Hackathon"
|
21 |
|
22 |
prompt_naming:
|
23 |
Science: "Science"
|
@@ -25,7 +23,6 @@ prompt_naming:
|
|
25 |
Organismes publics: "Organismes publics"
|
26 |
ADEME: "ADEME"
|
27 |
Presse: "Presse"
|
28 |
-
Hackathon: "Hackathon"
|
29 |
|
30 |
query_preprompt: "query: "
|
31 |
passage_preprompt: "passage: "
|
|
|
10 |
* *Des études et recherches sur des impacts locaux*\n
|
11 |
* *Des documents institutionnels (analyses demandées par la France & rapports d'activité)*\n
|
12 |
* *Les plans de transition sectoriels pour les secteurs industriels les plus émetteurs : (verre, papier, ciment, acier, aluminium, chimie, sucre)*"
|
|
|
13 |
|
14 |
source_mapping:
|
15 |
GIEC et IPBES: "Science"
|
16 |
Textes Juridiques: "Loi"
|
17 |
Organismes publics: "Organismes publics"
|
18 |
ADEME: "ADEME"
|
|
|
19 |
|
20 |
prompt_naming:
|
21 |
Science: "Science"
|
|
|
23 |
Organismes publics: "Organismes publics"
|
24 |
ADEME: "ADEME"
|
25 |
Presse: "Presse"
|
|
|
26 |
|
27 |
query_preprompt: "query: "
|
28 |
passage_preprompt: "passage: "
|
spinoza_project/source/frontend/gradio_utils.py
CHANGED
@@ -13,7 +13,7 @@ from spinoza_project.source.backend.document_store import pickle_to_document_sto
|
|
13 |
|
14 |
|
15 |
def get_config():
|
16 |
-
if os.getenv("
|
17 |
with open("./spinoza_project/config.yaml") as f:
|
18 |
return yaml.full_load(f)
|
19 |
|
@@ -58,7 +58,23 @@ def get_qdrants(config):
|
|
58 |
)
|
59 |
)
|
60 |
for tab in config["prompt_naming"]
|
61 |
-
if tab
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
}
|
63 |
|
64 |
return qdrants
|
|
|
13 |
|
14 |
|
15 |
def get_config():
|
16 |
+
if os.getenv("EKI_OPENAI_LLM_DEPLOYMENT_NAME"):
|
17 |
with open("./spinoza_project/config.yaml") as f:
|
18 |
return yaml.full_load(f)
|
19 |
|
|
|
58 |
)
|
59 |
)
|
60 |
for tab in config["prompt_naming"]
|
61 |
+
if tab in ["Science", "Loi", "Organismes publics", "ADEME"]
|
62 |
+
}
|
63 |
+
|
64 |
+
return qdrants
|
65 |
+
|
66 |
+
|
67 |
+
def get_qdrants_public(config, repo_id):
|
68 |
+
qdrants = {
|
69 |
+
tab: pickle_to_document_store(
|
70 |
+
hf_hub_download(
|
71 |
+
repo_id=repo_id,
|
72 |
+
filename=f"database_{tab}.pickle",
|
73 |
+
repo_type="dataset",
|
74 |
+
)
|
75 |
+
)
|
76 |
+
for tab in config["prompt_naming"]
|
77 |
+
if tab not in ["Science", "Loi", "Organismes publics", "ADEME", "Presse", "AFP"]
|
78 |
}
|
79 |
|
80 |
return qdrants
|