Abhilashvj commited on
Commit
16b2878
1 Parent(s): 7892c4e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -41
app.py CHANGED
@@ -3,6 +3,7 @@ import requests
3
  from io import BytesIO
4
  import base64
5
  import streamlit as st
 
6
 
7
  AUTH_TOKEN = st. secrets["AUTH_TOKEN"]
8
 
@@ -14,47 +15,44 @@ TMP_DIR = "./tmp"
14
 
15
  os.makedirs(TMP_DIR, exist_ok=True)
16
 
17
- st.title("Document Uploader and Chatbot Trainer")
18
 
19
- st.header("Upload Documents")
20
 
21
- # Upload evergreen document
22
- evergreen_file = st.file_uploader("Choose an Evergreen Document", type=['txt', 'pdf', 'doc', 'docx'])
23
- if evergreen_file:
24
- files = {'file': evergreen_file.getvalue()}
25
- response = requests.post(f'{CHAT_API}upload/evergreen/', files=files, headers=headers)
26
- if response.json().get("success"):
27
- st.success("Evergreen document uploaded successfully!")
28
- else:
29
- st.error("Failed to upload evergreen document!")
30
-
31
- # Upload dynamic document
32
- dynamic_file = st.file_uploader("Choose a Dynamic Document", type=['txt', 'pdf', 'doc', 'docx'])
33
- if dynamic_file:
34
- files = {'file': dynamic_file.getvalue()}
35
- response = requests.post(f'{CHAT_API}upload/dynamic/', files=files, headers=headers)
36
- if response.json().get("success"):
37
- st.success("Dynamic document uploaded successfully!")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  else:
39
- st.error("Failed to upload dynamic document!")
40
-
41
- # Train bot button
42
- # if st.button("Train Bot"):
43
- # response = requests.post('http://your_fastapi_endpoint/train/')
44
- # bot_url = response.json().get("bot_url")
45
- # if bot_url:
46
- # st.success(f"Bot trained successfully! Access the bot at {bot_url}")
47
- # else:
48
- # st.error("Failed to train the bot!")
49
-
50
- # Chat with bot
51
- st.header("Chat with Bot")
52
- user_input = st.text_input("Ask your question:")
53
- # Assuming you have an endpoint to send user questions and get responses
54
- data = {
55
- "text": user_input,
56
- "top_k": 5,
57
- }
58
- response = requests.post(f'{CHAT_API}/query/', json=data)
59
- bot_response = response.json().get("answer")
60
- st.text_area("Bot's Response:", value=bot_response)
 
3
  from io import BytesIO
4
  import base64
5
  import streamlit as st
6
+ import requests
7
 
8
  AUTH_TOKEN = st. secrets["AUTH_TOKEN"]
9
 
 
15
 
16
  os.makedirs(TMP_DIR, exist_ok=True)
17
 
 
18
 
 
19
 
20
+ st.title("Resume Reframing App")
21
+
22
+ # Uploading files using Streamlit
23
+ resume_file = st.file_uploader("Upload Resume", type=["txt", "pdf"])
24
+ template_file = st.file_uploader("Upload Template (Optional)", type=["txt", "pdf"], accept_multiple_files=False)
25
+ job_description_file = st.file_uploader("Upload Job Description (Optional)", type=["txt", "pdf"], accept_multiple_files=False)
26
+
27
+ # Inputs for QueryData
28
+ text_input = st.text_input("Enter your text:", "Your text here")
29
+ top_k = st.number_input("Top K", min_value=1, max_value=100, value=5)
30
+ primer = st.text_input("Enter primer:", "Your primer here")
31
+
32
+ if st.button("Submit"):
33
+ if resume_file:
34
+ # The URL to your FastAPI endpoint
35
+ url = f"{CHAT_API}/upload/"
36
+
37
+ # Setting up the data for the `QueryData` model
38
+ data = {
39
+ "text": text_input,
40
+ "top_k": top_k,
41
+ "primer": primer,
42
+ }
43
+
44
+ files = {"resume": resume_file.getvalue()}
45
+
46
+ if template_file:
47
+ files["template"] = template_file.getvalue()
48
+
49
+ if job_description_file:
50
+ files["job_description"] = job_description_file.getvalue()
51
+
52
+ # Making the POST request
53
+ response = requests.post(url, data=data, files=files)
54
+
55
+ # Displaying the response
56
+ st.write(response.json())
57
  else:
58
+ st.warning("Please upload a resume!")