Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,8 @@ import spacy
|
|
8 |
from spacy import displacy
|
9 |
import re
|
10 |
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
|
|
|
|
|
11 |
|
12 |
# Configure the page to use the full width
|
13 |
st.set_page_config(
|
@@ -21,6 +23,22 @@ from modules.morpho_analysis import get_repeated_words_colors, highlight_repeate
|
|
21 |
from modules.syntax_analysis import visualize_syntax
|
22 |
|
23 |
@st.cache_resource
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
def load_chatbot_model():
|
25 |
tokenizer = BlenderbotTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
|
26 |
model = BlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
|
|
|
8 |
from spacy import displacy
|
9 |
import re
|
10 |
from transformers import BlenderbotTokenizer, BlenderbotForConditionalGeneration
|
11 |
+
import pyodbc
|
12 |
+
from azure.identity import DefaultAzureCredential
|
13 |
|
14 |
# Configure the page to use the full width
|
15 |
st.set_page_config(
|
|
|
23 |
from modules.syntax_analysis import visualize_syntax
|
24 |
|
25 |
@st.cache_resource
|
26 |
+
def get_db_connection():
|
27 |
+
server = 'aideatexdb.database.windows.net'
|
28 |
+
database = 'textdb'
|
29 |
+
username = 'manuel.var.ale_aideatext.ai#EXT#@manuelvaraleaideatext.onmicrosoft.com'
|
30 |
+
connection_string = f'Driver={{ODBC Driver 18 for SQL Server}};Server={server};Database={database}'
|
31 |
+
|
32 |
+
credential = DefaultAzureCredential()
|
33 |
+
token = credential.get_token("https://database.windows.net/.default")
|
34 |
+
|
35 |
+
conn = pyodbc.connect(connection_string,
|
36 |
+
attrs_before = {1256: f'Bearer {token.token}'})
|
37 |
+
return conn
|
38 |
+
|
39 |
+
|
40 |
+
|
41 |
+
|
42 |
def load_chatbot_model():
|
43 |
tokenizer = BlenderbotTokenizer.from_pretrained("facebook/blenderbot-400M-distill")
|
44 |
model = BlenderbotForConditionalGeneration.from_pretrained("facebook/blenderbot-400M-distill")
|