Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from transformers import pipeline | |
| import docx | |
| #from datasets import load_dataset | |
| file_path = "Adrega_P.I._User_Manual.docx" | |
| #def read_docx(file_path): | |
| # doc = docx.Document(file_path) | |
| # text = [] | |
| # for paragraph in doc.paragraphs: | |
| # text.append(paragraph.text) | |
| # return "\n".join(text) | |
| #pipe = pipeline("question-answering") | |
| #pipe = pipeline("text-generation") | |
| #pipe = pipeline("question-answering", model="deepset/roberta-base-squad2") | |
| pipe = pipeline("text-generation", model="meta-llama/Llama-3.2-3B-Instruct") | |
| st.title("Adrega AI Help") | |
| #dataset = load_dataset("andreska/adregadocs", split="test") | |
| #context = read_docx(file_path) | |
| #context = dataset[0]["text"] | |
| context = "Adrega is a very cool company, that implements AI. Rett fra Rio is a company that specializes in body waxing and is owned by Cintia" #dataset[0]["text"] | |
| user_input = st.text_input('Ask me a question') | |
| if st.button("Submit"): | |
| if user_input: | |
| answer = pipe(f"Context: {context}\nQuestion: {user_input}\nAnswer:", max_length=512, num_return_sequences=1) | |
| #result = pipe(text_inputs, max_length=200, num_return_sequences=1)[0]['generated_text'] | |
| #answer = result.split("Answer:")[1].strip() | |
| #answer = pipe(question=user_input, context=context) | |
| st.write(f"Adrega AI: {answer[0]['generated_text']}") | |
| #st.write(f"Adrega AI: {answer}") | |
| else: | |
| st.write("Please enter a question.") | |