from pyexpat import model from transformers import GPT2LMHeadModel, GPT2Tokenizer from streamlit_lottie import st_lottie import json import pandas as pd import requests import torch import tensorflow as tf import streamlit as st from streamlit_option_menu import option_menu logo = "https://www.google.com/url?sa=i&url=https%3A%2F%2Ffr.depositphotos.com%2Fvector-images%2Frobot-logo.html&psig=AOvVaw14rAtmwJQVSpRFXFY6us7z&ust=1647274982461000&source=images&cd=vfe&ved=0CAsQjRxqFwoTCPjhzdO_w_YCFQAAAAAdAAAAABAD" st.set_page_config(page_icon = logo, page_title ="Bonsoir !", layout = "wide") @st.cache(allow_output_mutation=True) def load_tokenizer(): tokenizer = GPT2Tokenizer.from_pretrained("gpt2-large") model = GPT2LMHeadModel.from_pretrained("gpt2-large", pad_token_id=tokenizer.eos_token_id) return tokenizer @st.cache(allow_output_mutation=True) def load_model(): model = GPT2LMHeadModel.from_pretrained("gpt2-large", pad_token_id=tokenizer.eos_token_id) return model tokenizer =load_tokenizer() model = load_model() def reponse(question, temp=0.5, long=40): input_ids = tokenizer.encode(question, return_tensors='pt') output = model.generate(input_ids, max_length=long, temperature =temp, num_beams=5, no_repeat_ngram_size=2, early_stopping=True) rep = tokenizer.decode(output[0], skip_special_tokens=True) return rep def load_animation(url: str): r = requests.get(url) if r.status_code != 200 : return None return r.json() url = "https://assets10.lottiefiles.com/packages/lf20_96bovdur.json" robot = load_animation(url) def contact_message(): st.header(":mailbox: Let's Get In Touch !") name, message = st.columns((1,2)) with name: contact_form = """
""" st.markdown(contact_form, unsafe_allow_html=True) with message : contact_form2 = """