MatteoScript commited on
Commit
1cf51b9
·
verified ·
1 Parent(s): f2c629a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -11
app.py CHANGED
@@ -31,9 +31,13 @@ options = {
31
 
32
  st.set_page_config(page_title="BonsiAI", page_icon="🤖")
33
 
34
- def gen_augmented_prompt(prompt, top_k) :
35
- context = ""
36
  links = ""
 
 
 
 
 
37
  generated_prompt = f"""
38
  A PARTIRE DAL SEGUENTE CONTESTO: {context},
39
 
@@ -157,19 +161,10 @@ def show_source(links) :
157
  for i, link in enumerate(links) :
158
  st.info(f"{link}")
159
 
160
- def init_vector_db():
161
- persist_directory1 = './DB_Decreti'
162
- embedding = HuggingFaceEmbeddings(model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
163
- db = Chroma(persist_directory=persist_directory1, embedding_function=embedding)
164
- #NumeroDocumenti = 10
165
- #query = 'Come funziona la generazione delle PDA'
166
- #result = db.similarity_search(query, k=NumeroDocumenti)
167
-
168
  init_state()
169
  sidebar()
170
  header()
171
  chat_box()
172
- init_vector_db()
173
 
174
  if prompt := st.chat_input("Chatta con BonsiAI..."):
175
  st.chat_message("user").markdown(prompt)
 
31
 
32
  st.set_page_config(page_title="BonsiAI", page_icon="🤖")
33
 
34
+ def gen_augmented_prompt(prompt, top_k) :
 
35
  links = ""
36
+ persist_directory1 = './DB_Decreti'
37
+ embedding = HuggingFaceEmbeddings(model_name="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2")
38
+ db = Chroma(persist_directory=persist_directory1, embedding_function=embedding)
39
+ context = db.similarity_search(prompt, k=top_k)
40
+ print(context)
41
  generated_prompt = f"""
42
  A PARTIRE DAL SEGUENTE CONTESTO: {context},
43
 
 
161
  for i, link in enumerate(links) :
162
  st.info(f"{link}")
163
 
 
 
 
 
 
 
 
 
164
  init_state()
165
  sidebar()
166
  header()
167
  chat_box()
 
168
 
169
  if prompt := st.chat_input("Chatta con BonsiAI..."):
170
  st.chat_message("user").markdown(prompt)