arunks/RAG-Retrieval.Augmented.Generation
0
1 2import streamlit as st3from transformers import pipeline4import io5 6# Load the model7generator = pipeline("text-generation", model="EleutherAI/gpt-neo-1.3B")8 9# Streamlit app10def main():11 st.title("Text Generation with GPT-Neo")12 13 # Input text area14 input_text = st.text_area("Input Text", "")15 16 # File uploader for PDF files17 uploaded_file = st.file_uploader("Upload a PDF file", type=["pdf"])18 19 # Generate button20 if st.button("Generate"):21 if input_text:22 # Generate text based on the input text23 output_text = generator(input_text, max_length=50, do_sample=True, temperature=0.7)[0]['generated_text']24 st.write(output_text)25 elif uploaded_file is not None:26 # Read the uploaded PDF file27 with io.BytesIO(uploaded_file.read()) as f:28 # Process the PDF file and generate text29 # (Add your PDF processing and text generation code here)30 # For demonstration purposes, we'll just echo the content of the PDF file31 pdf_content = f.read().decode("utf-8")32 st.write("Content of the uploaded PDF file:")33 st.write(pdf_content)34 else:35 st.error("Please enter some input text or upload a PDF file.")36 37if __name__ == "__main__":38 main()39 