Code Monkey home page Code Monkey logo

Comments (2)

abidlabs avatar abidlabs commented on August 29, 2024

Hi @geektian thanks, you're right this behavior is unintuitive. The reason is that when components are instantiated inside of a gr.Blocks context, they are rendered immediately. If you don't want this behavior, you can pass in render=False. This will produce the UI that you have in mind:

import gradio as gr
def echo_system_prompt_plus_message(message, history, system_prompt, tokens):
    response = f"{system_prompt} {message}"
    for i in range(min(len(response), int(tokens))):
        yield response[: i + 1]


with gr.Blocks() as demo:
   gr.ChatInterface(
        echo_system_prompt_plus_message,
        additional_inputs=[
                            gr.Textbox(label="System Prompt", render=False),
                            gr.Slider(2, 8192, value=1024,step = 8, label="max_tokens", render=False)        
                        ],
        additional_inputs_accordion=gr.Accordion(open=True, label="MOAR", render=False),
    )

demo.launch()

from gradio.

geektian avatar geektian commented on August 29, 2024

oh,thank you!I couldn't find the usage in the official documentation before, it's a great help!
image

from gradio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.