Skip to content

Layout của streamlit #13

@hoangSnapeV

Description

@hoangSnapeV

Em chào anh, em là Vũ. Em có clone repo của anh về và sửa lại 1 tí.
Em có chia ra 2 tabs: tab1, tab2 = st.tabs(["Chat", "Contact"]). Ở đây em add vô đoạn main thì vấn đề chỗ input nhập vào. Nó luôn nằm ở trên đầu chứ không nằm dưới như giao diện của anh.
Em có đề hình ảnh dưới ạ và nó

image

Đây là đoạn code em thêm vào. Em có fix mà không được mong anh giải đáp dùm
Em cảm ơn.
""""
tab1, tab2 = st.tabs(["Chat", "Contact"])

with tab1:
# Các phần cấu hình trong thanh bên
model_choice, collection_to_query = setup_sidebar()

# Giao diện chat
msgs = setup_chat_interface(model_choice)

# Khởi tạo AI dựa trên lựa chọn model để trả lời
if model_choice == "OpenAI GPT-4":
    retriever = get_openai_retriever(collection_to_query)
    agent_executor = get_openai_agent(retriever, "gpt4")
elif model_choice == "OpenAI Grok":
    retriever = get_openai_retriever(collection_to_query)
    agent_executor = get_openai_agent(retriever, "grok")
else:
    retriever = get_ollama_retriever(collection_to_query)
    agent_executor = get_ollama_agent(retriever)

# Đảm bảo tin nhắn được xử lý trước khi hiển thị ô nhập liệu
handle_user_input(msgs, agent_executor)

# Đảm bảo ô nhập liệu luôn ở dưới cùng bằng cách tạo không gian trống
input_placeholder = st.empty()  # Chỗ để hiển thị ô nhập liệu

# Gọi hàm xử lý nhập liệu ở cuối tab
with input_placeholder:
    prompt = st.chat_input("Hãy hỏi tôi bất cứ điều gì về Stack AI!")
    if prompt:
        handle_user_input(msgs, agent_executor)

with tab2:
# Hiển thị thông tin liên hệ trong tab Contact
show_contact()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions