medelharchaoui commited on
Commit
bafe355
1 Parent(s): d38abec

create app

Browse files
Files changed (1) hide show
  1. app.py +62 -0
app.py ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
3
+ import requests
4
+ import pandas as pd
5
+
6
+ url = 'https://elharchaouiresume.s3.eu-west-3.amazonaws.com/resume'
7
+ response = requests.get(url)
8
+ resume_context=None
9
+
10
+ if response.status_code == 200:
11
+ resume_context = response.text
12
+ else:
13
+ load_error=f"Conext loading Error: {response.status_code}"
14
+
15
+ # with open('resume') as f:
16
+ # resume_context = f.read()
17
+
18
+ model_name = "deepset/tinyroberta-squad2"
19
+
20
+ # a) Get predictions
21
+ nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
22
+
23
+
24
+ # Streamlit app layout
25
+ st.title("Ask me any question about my career")
26
+ st.write("This app uses a pre-trained model from Hugging Face to perform question answering, about my career as context, on user input.")
27
+
28
+ # User input
29
+ user_input = st.text_area("Enter some a question :", value="", height=150, max_chars=500)
30
+
31
+ if user_input:
32
+
33
+ if resume_context:
34
+ print(resume_context)
35
+ QA_input = {
36
+ 'question': user_input,
37
+ 'context': resume_context
38
+ }
39
+ # Perform sentiment analysis on the user input
40
+ result = nlp(QA_input)
41
+
42
+ # Display the sentiment analysis result
43
+ answer = result["answer"]
44
+ else:
45
+ answer="It seems there is a problem loading context, here is more details :"+load_error
46
+
47
+ st.write(f"Response: {answer}")
48
+ else:
49
+ st.write("Please enter some text to analyze.")
50
+
51
+ # Display a table with example inputs
52
+ st.write("Example inputs:")
53
+
54
+ example_inputs = [
55
+ {"Inputs example": "What programming languages you have experience in?"},
56
+ {"Inputs example": "What cloud platforms are you familiar with?"},
57
+ {"Inputs example": "What are your skills in machine learning?"},
58
+ {"Inputs example": "The future of technology is..."},
59
+ ]
60
+
61
+ example_df = pd.DataFrame(example_inputs)
62
+ st.table(example_df)