Help me to fix the error of the following code:
"
import os
import time
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, TextIteratorStreamer, BitsAndBytesConfig
import gradio as gr
from threading import Thread
from PyPDF2 import PdfReader
import pandas as pd  # For Excel generation

MODEL_PATH = r"C:\Users\shermanhonsf\Desktop\Python\llama_develop\model\Llama3.2-1B-Instruct-HF-Model"

TITLE = """
Chat with Llama 3.2 1B
"""

PLACEHOLDER = """
Hi, I'm Llama. Ask me anything or upload a PDF to chat about its content. You can also ask me to generate an Excel file.
"""

CSS = """
.duplicate-button {
    margin: auto !important;
    color: white !important;
    background: black !important;
    border-radius: 100vh !important;
}
h3 {
    text-align: center;
}
"""

device = "cuda" if torch.cuda.is_available() else "cpu"

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_compute_dtype=torch.bfloat16,
    bnb_4bit_use_double_quant=True,
    bnb_4bit_quant_type="nf4"
)

tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH)
model = AutoModelForCausalLM.from_pretrained(
    MODEL_PATH,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    # quantization_config=quantization_config
)

model.to(device)


def extract_pdf_text(pdf_path):
    try:
        reader = PdfReader(pdf_path)
        text = ""
        for page in reader.pages:
            text += page.extract_text()
        return text
    except Exception as e:
        return f"Error reading PDF: {e}"


def process_llm_output_to_excel(llm_output):
    """
    Convert the LLM-generated text into a structured DataFrame for Excel.
    Assumes the LLM output is a numbered list or similar structured text.
    """
    try:
        # Split the LLM output into lines
        lines = llm_output.strip().split("\n")
        data = []

        for line in lines:
            # Extract step number and description
            parts = line.split(".", 1)
            if len(parts) == 2:
                step_number, description = parts[0].strip(), parts[1].strip()
                data.append({"Step Number": step_number, "Description": description})

        # Convert to DataFrame
        df = pd.DataFrame(data)
        return df
    except Exception as e:
        print(f"Error processing LLM output to Excel: {e}")
        return None


def save_excel(df, file_name="generated_data.xlsx"):
    """Save a DataFrame to an Excel file."""
    excel_file_path = file_name
    df.to_excel(excel_file_path, index=False)
    return excel_file_path


def stream_chat(message: str, history: list, system_prompt: str = 'You are a helpful assistant',
                temperature: float = 0.8, max_new_tokens: int = 1024, top_p: float = 1.0, top_k: int = 20, penalty: float = 1.2, pdf_text: str = ""):
    print(f'message: {message}')
    print(f'history: {history}')
    print(f'system_prompt: {system_prompt}')
    print(f'temperature: {temperature}')
    print(f'max_new_tokens: {max_new_tokens}')
    print(f'top_p: {top_p}')
    print(f'top_k: {top_k}')
    print(f'penalty: {penalty}')
    print(f'Message: {message}')
    print(f'History: {history}')
    print(f'PDF Text: {pdf_text}')

    conversation = [
        {"role": "system", "content": system_prompt}
    ]

    if pdf_text.strip():
        pdf_summary = f"The user uploaded a PDF with the following content:\n{pdf_text[:2000]}...\n(This is a truncated summary if the text is too long.)"
        conversation.append({"role": "system", "content": pdf_summary})

    for prompt, answer in history:
        conversation.extend([
            {"role": "user", "content": prompt},
            {"role": "assistant", "content": answer},
        ])

    conversation.append({"role": "user", "content": message})

    input_ids = tokenizer.apply_chat_template(
        conversation,
        add_generation_prompt=True,
        return_tensors="pt"
    ).to(device)

    streamer = TextIteratorStreamer(
        tokenizer,
        timeout=60.0,
        skip_prompt=True,
        skip_special_tokens=True
    )

    generate_kwargs = dict(
        input_ids=input_ids,
        max_new_tokens=max_new_tokens,
        do_sample=False if temperature == 0 else True,
        top_p=top_p,
        top_k=top_k,
        temperature=temperature,
        eos_token_id=[128001, 128008, 128009],
        streamer=streamer,
    )

    with torch.no_grad():
        thread = Thread(target=model.generate, kwargs=generate_kwargs)
        thread.start()

    buffer = ""
    for new_text in streamer:
        buffer += new_text
        yield buffer


chatbot = gr.Chatbot(height=600, show_copy_button=True, layout="panel", placeholder=PLACEHOLDER)

with gr.Blocks(css=CSS) as demo:
    gr.HTML(TITLE)
    
    pdf_file = gr.File(label="Upload PDF", type="filepath")
    pdf_textbox = gr.Textbox(label="Extracted PDF Text", placeholder="PDF content will appear here after upload.", lines=10, interactive=False)
    
    def process_pdf(file):
        if file is not None:
            pdf_text = extract_pdf_text(file.name)
            return pdf_text
        return "No PDF uploaded."

    pdf_file.change(process_pdf, inputs=pdf_file, outputs=pdf_textbox)
    
    # DataFrame for Excel editing
    excel_df = gr.DataFrame(label="Generated Excel Data", interactive=True)

    # Downloadable Excel file
    download_button = gr.File(label="Download Excel File")

    # Logic for generating Excel from LLM response
    def generate_excel_from_llm(message, history):
        # Get the latest LLM response
        llm_response = next(stream_chat(message, history, "You are a helpful assistant"))
        
        # Process LLM output into a DataFrame
        df = process_llm_output_to_excel(llm_response)
        if df is not None:
            excel_file_path = save_excel(df)
            return df, excel_file_path
        return None, None

    # Button to trigger Excel generation
    generate_excel_button = gr.Button("Generate Excel File")
    generate_excel_button.click(
        generate_excel_from_llm,
        inputs=[chatbot.input, chatbot.state],
        outputs=[excel_df, download_button]
    )
    
    gr.ChatInterface(
        fn=stream_chat,
        chatbot=chatbot,
        additional_inputs_accordion=gr.Accordion(
            label="⚙️ Parameters",
            open=False,
            render=False
        ),
        additional_inputs=[
            gr.Textbox(
                value="You are a helpful assistant",
                label="System Prompt",
                render=False,
            ),
            gr.Slider(
                minimum=0,
                maximum=1,
                step=0.1,
                value=0.8,
                label="Temperature",
                render=False,
            ),
            gr.Slider(
                minimum=128,
                maximum=8192,
                step=1,
                value=1024,
                label="Max new tokens",
                render=False,
            ),
            gr.Slider(
                minimum=0.0,
                maximum=1.0,
                step=0.1,
                value=1.0,
                label="Top_p",
                render=False,
            ),
            gr.Slider(
                minimum=1,
                maximum=20,
                step=1,
                value=20,
                label="Top_k",
                render=False,
            ),
            gr.Slider(
                minimum=0.0,
                maximum=2.0,
                step=0.1,
                value=1.2,
                label="Repetition penalty",
                render=False,
            ),
            pdf_textbox
        ]
    )

if __name__ == "__main__":
    demo.launch(debug=True)
"
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 197
    193     # Button to trigger Excel generation
    194     generate_excel_button = gr.Button("Generate Excel File")
    195     generate_excel_button.click(
    196         generate_excel_from_llm,
--> 197         inputs=[chatbot.input, chatbot.state],
    198         outputs=[excel_df, download_button]
    199     )
    201     gr.ChatInterface(
    202         fn=stream_chat,
    203         chatbot=chatbot,
   (...)
    256         ]
    257     )
    259 if __name__ == "__main__":

AttributeError: 'Chatbot' object has no attribute 'input'