Spaces:
Sleeping
Sleeping
Update app.py
Browse files18 unmodified lines1920212223242526272829303132333435368 unmodified lines4546474849505152531 unmodified line555657585960619 unmodified lines71727318 unmodified linesif val[1]:messages.append({"role": "assistant", "content": val[1]})# 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})response = ""8 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 response1 unmodified linedemo = 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(9 unmodified linesif __name__ == "__main__":demo.launch()18 unmodified lines19202122232425262728293031323334353637388 unmodified lines4748495051525354551 unmodified line575859606162639 unmodified lines7374757618 unmodified linesif val[1]:messages.append({"role": "assistant", "content": val[1]})# Provide the reasoning without revealing the final sequenceformatted_prompt = f"""You are a chatbot that helps users think through a sequence of words.Provide reasoning for each part of the sequence:1. For the first word, describe an animal.2. For the second word, give a clue for a fruit.3. For the third word, describe the color itself.DO NOT give away the final sequence. Instead, offer clues that will guide the user to think creatively and connect the words themselves.Now, help me think through this sequence: "{message}""""messages.append({"role": "user", "content": formatted_prompt})response = ""8 unmodified linestoken = message.choices[0].delta.contentresponse += token# Ensure the response is just reasoning and hints, not the answerif len(response.split()) > 50: # Prevent long explanationsresponse = "Let's break it down:\n1. Think of an animal often linked to the color orange.\n2. Now, consider a fruit of the same color.\n3. Finally, what's the color that connects both?"yield response1 unmodified linedemo = gr.ChatInterface(respond,additional_inputs=[gr.Textbox(value="You are a chatbot that helps users think through a sequence of words. Provide structured clues and avoid giving the final sequence directly.", 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(9 unmodified linesif __name__ == "__main__":demo.launch()
app.py+14-11