LightRT commited on
Commit
ca8e3f6
·
verified ·
1 Parent(s): 0810aa9

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +14 -2
src/streamlit_app.py CHANGED
@@ -2,10 +2,22 @@ import streamlit as st
2
  import requests
3
  import uuid
4
  import os
 
 
 
5
 
6
- # Grab the token from Hugging Face secrets
7
  HF_TOKEN = os.getenv("HF_TOKEN")
8
- HEADERS = {"Authorization": f"Bearer {HF_TOKEN}"} if HF_TOKEN else {}
 
 
 
 
 
 
 
 
 
 
9
 
10
  # 1. PAGE CONFIGURATION
11
  st.set_page_config(page_title="Text2SQL Agent", page_icon="🤖", layout="centered")
 
2
  import requests
3
  import uuid
4
  import os
5
+ from dotenv import load_dotenv()
6
+
7
+ load_dotenv()
8
 
 
9
  HF_TOKEN = os.getenv("HF_TOKEN")
10
+
11
+ # We are disguising the request to look exactly like a Google Chrome browser
12
+ HEADERS = {
13
+ "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
14
+ "Accept": "application/json",
15
+ "Content-Type": "application/json"
16
+ }
17
+
18
+ # Add the token if it exists
19
+ if HF_TOKEN:
20
+ HEADERS["Authorization"] = f"Bearer {HF_TOKEN}"
21
 
22
  # 1. PAGE CONFIGURATION
23
  st.set_page_config(page_title="Text2SQL Agent", page_icon="🤖", layout="centered")