t0mkaka commited on
Commit
187e1c4
·
1 Parent(s): 832c979

Addind sqlite

Browse files
Files changed (3) hide show
  1. .gitignore +2 -1
  2. app.py +0 -1
  3. mvp.py +16 -1
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  __pycache__/*
2
  vtt_files/*
3
- venv/*
 
 
1
  __pycache__/*
2
  vtt_files/*
3
+ venv/*
4
+ rag.db
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
  import requests
3
  from mvp import tbl
4
- import sqlite3
5
 
6
  # # Function to call your system API and get the response
7
  # def search_question(question):
 
1
  import gradio as gr
2
  import requests
3
  from mvp import tbl
 
4
 
5
  # # Function to call your system API and get the response
6
  # def search_question(question):
mvp.py CHANGED
@@ -21,6 +21,21 @@ embedding_model = SentenceTransformer(model_name)
21
  model_registry = get_registry().get("sentence-transformers")
22
  model = model_registry.create(name="BAAI/bge-small-en-v1.5")
23
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  class Document(LanceModel):
25
  text: str = model.SourceField()
26
  vector: Vector(384) = model.VectorField()
@@ -63,7 +78,7 @@ def read_chunks_from_db(db_path):
63
  reranker = ColbertReranker()
64
 
65
  # Function to log the interaction to the SQLite database
66
- def log_interaction(question, chunks, coherent_answer, feedback=None, additional_feedback=None, db_path='rag.db'):
67
  conn = sqlite3.connect(db_path)
68
  cursor = conn.cursor()
69
  cursor.execute('''
 
21
  model_registry = get_registry().get("sentence-transformers")
22
  model = model_registry.create(name="BAAI/bge-small-en-v1.5")
23
 
24
+ def create_interactions(db_path = "/data/rag.db"):
25
+ conn = sqlite3.connect(db_path)
26
+ cursor = conn.cursor()
27
+ cursor.execute("""CREATE TABLE IF NOT EXISTS interactions (
28
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
29
+ question TEXT,
30
+ chunks TEXT,
31
+ coherent_answer TEXT,
32
+ feedback TEXT,
33
+ additional_feedback TEXT
34
+ )""")
35
+ conn.close()
36
+
37
+ create_interactions()
38
+
39
  class Document(LanceModel):
40
  text: str = model.SourceField()
41
  vector: Vector(384) = model.VectorField()
 
78
  reranker = ColbertReranker()
79
 
80
  # Function to log the interaction to the SQLite database
81
+ def log_interaction(question, chunks, coherent_answer, feedback=None, additional_feedback=None, db_path='/data/rag.db'):
82
  conn = sqlite3.connect(db_path)
83
  cursor = conn.cursor()
84
  cursor.execute('''