File size: 1,885 Bytes
bafe355
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import streamlit as st
from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipeline
import requests
import pandas as pd

url = 'https://elharchaouiresume.s3.eu-west-3.amazonaws.com/resume'
response = requests.get(url)
resume_context=None

if response.status_code == 200:
    resume_context = response.text
else:
    load_error=f"Conext loading Error: {response.status_code}"

# with open('resume') as f:
#     resume_context = f.read()

model_name = "deepset/tinyroberta-squad2"

# a) Get predictions
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)


# Streamlit app layout
st.title("Ask me any question about my career")
st.write("This app uses a pre-trained model from Hugging Face to perform question answering, about my career as context, on user input.")

# User input
user_input = st.text_area("Enter some a question :", value="", height=150, max_chars=500)

if user_input:

    if resume_context:
        print(resume_context)
        QA_input = {
            'question': user_input,
            'context': resume_context
        }
        # Perform sentiment analysis on the user input
        result = nlp(QA_input)

        # Display the sentiment analysis result
        answer = result["answer"]
    else:
        answer="It seems there is a problem loading context, here is more details :"+load_error

    st.write(f"Response: {answer}")
else:
    st.write("Please enter some text to analyze.")

# Display a table with example inputs
st.write("Example inputs:")

example_inputs = [
    {"Inputs example": "What programming languages you have experience in?"},
    {"Inputs example": "What cloud platforms are you familiar with?"},
    {"Inputs example": "What are your skills in machine learning?"},
    {"Inputs example": "The future of technology is..."},
]

example_df = pd.DataFrame(example_inputs)
st.table(example_df)