Léo Bourrel commited on
Commit
bdc3272
·
1 Parent(s): c44f270

feat: split connection

Browse files
Files changed (2) hide show
  1. app.py +1 -11
  2. connection.py +11 -0
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import json
2
  import os
3
 
4
- import sqlalchemy
5
  import streamlit as st
6
  import streamlit.components.v1 as components
7
  from langchain.callbacks import get_openai_callback
@@ -14,8 +13,7 @@ from chat_history import insert_chat_history, insert_chat_history_articles
14
  from css import load_css
15
  from custom_pgvector import CustomPGVector
16
  from message import Message
17
-
18
- CONNECTION_STRING = "postgresql+psycopg2://postgres@/sorbobot?host=0.0.0.0"
19
 
20
  st.set_page_config(layout="wide")
21
 
@@ -23,14 +21,6 @@ st.title("Sorbobot - Le futur de la recherche scientifique interactive")
23
 
24
  chat_column, doc_column = st.columns([2, 1])
25
 
26
-
27
- def connect() -> sqlalchemy.engine.Connection:
28
- engine = sqlalchemy.create_engine(CONNECTION_STRING, pool_pre_ping=True)
29
-
30
- conn = engine.connect()
31
- return conn
32
-
33
-
34
  conn = connect()
35
 
36
 
 
1
  import json
2
  import os
3
 
 
4
  import streamlit as st
5
  import streamlit.components.v1 as components
6
  from langchain.callbacks import get_openai_callback
 
13
  from css import load_css
14
  from custom_pgvector import CustomPGVector
15
  from message import Message
16
+ from connection import connect
 
17
 
18
  st.set_page_config(layout="wide")
19
 
 
21
 
22
  chat_column, doc_column = st.columns([2, 1])
23
 
 
 
 
 
 
 
 
 
24
  conn = connect()
25
 
26
 
connection.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sqlalchemy
2
+
3
+
4
+ CONNECTION_STRING = "postgresql+psycopg2://postgres@/sorbobot?host=0.0.0.0"
5
+
6
+
7
+ def connect() -> sqlalchemy.engine.Connection:
8
+ engine = sqlalchemy.create_engine(CONNECTION_STRING, pool_pre_ping=True)
9
+
10
+ conn = engine.connect()
11
+ return conn