Spaces:
Sleeping
Sleeping
Update app.py
Browse files20 unmodified lines2122232425262728293010 unmodified lines41424344454647484950515253545556576 unmodified lines64656667686920 unmodified lines# Formatting the user input to focus on reasoningformatted_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.Now, explain the reasoning behind: "{message}""""messages.append({"role": "user", "content": formatted_prompt})10 unmodified linestoken = message.choices[0].delta.contentresponse += token# Limit the response to concise explanationsif len(response.split()) > 50: # Prevent long explanationsresponse = "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."yield responsedemo = 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.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)20 unmodified lines212223242526272829303132333410 unmodified lines45464748495051525354555657585960616 unmodified lines68697071727320 unmodified lines# Formatting the user input to focus on reasoningformatted_prompt = f"""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: orangeFruit: 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 linestoken = message.choices[0].delta.contentresponse += token# Ensuring the output is structured and concise without revealing the answerif len(response.split()) > 50: # Prevent long explanationsresponse = "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 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()
app.py+14-10