Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| # Gradio application setup | |
| def create_demo(): | |
| with gr.Blocks(title="LLAMA 3 Rag on Fly", theme="Monochrome") as demo: | |
| # App Description | |
| gr.Markdown( | |
| """ | |
| ## LLAMA 3 Rag on Fly App | |
| This application allows you to experiment with a LLAMA 3 model for RAG powered Chatbot. | |
| You can adjust various parameters to control the model's output. | |
| """ | |
| ) | |
| with gr.Column(): | |
| with gr.Row(): | |
| chat_history = gr.Chatbot(value=[], elem_id='chatbot', height=480) | |
| show_img = gr.Image(label='Overview', height=480) | |
| # Sliders in the Rightmost Column | |
| with gr.Column(): | |
| with gr.Row(): | |
| slider_chunk_size = gr.Slider( | |
| minimum=256, maximum=1024, value=256, label="Chunk Size", elem_id='slider1' | |
| ) | |
| gr.Markdown( | |
| """ | |
| **Chunk Size:** Controls the size of text chunks processed by the model. Larger chunks | |
| provide more context but may increase processing time. | |
| """ | |
| ) | |
| with gr.Row(): | |
| slider_overlap_percentage = gr.Slider( | |
| minimum=0, maximum=100, value=50, label="Chunk Overlap Percentage", elem_id='slider2' | |
| ) | |
| gr.Markdown( | |
| """ | |
| **Chunk Overlap Percentage:** Determines the percentage of overlap between consecutive | |
| chunks. Higher overlap can improve coherence but may also increase redundancy. | |
| """ | |
| ) | |
| with gr.Row(): | |
| slider_temp = gr.Slider( | |
| minimum=0, maximum=1, value=0.5, label="Model Temperature", elem_id='slider3' | |
| ) | |
| gr.Markdown( | |
| """ | |
| **Model Temperature:** Controls the randomness of the generated text. Higher temperature | |
| leads to more creative and unpredictable outputs, while lower temperature results | |
| in more conservative and deterministic text. | |
| """ | |
| ) | |
| with gr.Row(): | |
| slider_k = gr.Slider( | |
| minimum=1, maximum=5, value=2, label="Max Chunks in Context", elem_id='slider2' | |
| ) | |
| gr.Markdown( | |
| """ | |
| **Max Chunks in Context:** Determines the number of previous chunks considered by the | |
| model when generating text. More chunks provide more context but may also increase | |
| processing time. | |
| """ | |
| ) | |
| with gr.Row(): | |
| with gr.Column(scale=0.60): | |
| text_input = gr.Textbox( | |
| show_label=False, | |
| placeholder="Type here to ask your PDF", | |
| container=False) | |
| with gr.Column(scale=0.20): | |
| submit_button = gr.Button('Send') | |
| with gr.Column(scale=0.20): | |
| uploaded_pdf = gr.UploadButton("π Upload PDF", file_types=[".pdf"], elem_id='upload_pdf') | |
| return demo, chat_history, show_img, text_input, submit_button, uploaded_pdf, slider_chunk_size,slider_overlap_percentage,slider_temp,slider_k | |
| if __name__ == '__main__': | |
| demo, chatbot, show_img, text_input, submit_button, uploaded_pdf, slider_chunk_size,slider_overlap_percentage,slider_temp,slider_k = create_demo() | |
| demo.queue() | |
| demo.launch() | |