Spaces:
Sleeping
Sleeping
Update app.py
Browse files20 unmodified lines21222324252627242526272829303132333410 unmodified lines4546474448494650515253505455565754585960616 unmodified lines686970677169727320 unmodified lines
# Formatting the user input to focus on reasoning formatted_prompt = f""" You are a chatbot that provides a structured, concise sequence without long explanations. For example: "I'm thinking of an animal that's commonly orange, then a fruit that shares the same color, and finally, a color that matches both." Do NOT provide long descriptive explanations. You are a chatbot that provides a structured sequence reasoning without long explanations or revealing the final sequence. Provide reasoning by structuring the clues like: Animal: orange tiger (commonly orange) Color: orange Fruit: orange (shares the same color)
Do NOT give away the final sequence directly. Instead, help the user think through the sequence.
Now, explain the reasoning behind: "{message}" """ messages.append({"role": "user", "content": formatted_prompt})10 unmodified lines token = message.choices[0].delta.content response += token
# Limit the response to concise explanations # Ensuring the output is structured and concise without revealing the answer if len(response.split()) > 50: # Prevent long explanations response = "I'm thinking of an animal that's commonly orange, then a fruit that shares the same color, and finally, a color that matches both." response = "Animal: orange tiger (commonly orange)\nColor: orange\nFruit: orange (shares the same color)\nSequence: orange tiger (Animal) -> orange (Color) -> orange (Fruit)"
yield response
# Gradio interface setupdemo = gr.ChatInterface( respond, additional_inputs=[ gr.Textbox(value="You are a chatbot that provides a structured, concise sequence without long explanations.", label="System message"), gr.Textbox(value="You are a chatbot that helps users think through a sequence of words. Provide a structured and concise reasoning without revealing the final sequence.", label="System message"), gr.Slider(minimum=1, maximum=2048, value=512, step=1, label="Max new tokens"), gr.Slider(minimum=0.1, maximum=4.0, value=0.7, step=0.1, label="Temperature"), gr.Slider(6 unmodified lines ],)
if __name__ == "__main__": demo.launch(server_name="0.0.0.0", server_port=7860) demo.launch()
app.py+14-10