Spaces:
Sleeping
Sleeping
Update app.py
Browse files18 unmodified lines1920212223242526272829303132333411 unmodified lines464748495051525354555657581 unmodified line606162636465668 unmodified lines757677787918 unmodified linesif val[1]:messages.append({"role": "assistant", "content": val[1]})# Guide the user through the reasoning process, without revealing the final sequenceformatted_prompt = f"""You are a chatbot that helps users think through the connections between an animal, a fruit, and a color.Provide reasoning for each part of the sequence without giving the final answer:1. For the first word (the animal), explain how the animal is typically associated with a specific characteristic (e.g., its color, habitat, or a notable feature).2. For the second word (the fruit), describe how the fruit shares this same characteristic or feature with the animal.3. For the third word (the color), explain why this color can be connected to both the animal and fruit.Do NOT give away the final sequence. Offer clues that help the user think creatively and make the connection themselves.Now, help me think through this sequence: "{message}""""11 unmodified linestoken = message.choices[0].delta.contentresponse += token# Ensure that the response focuses on clues, not the sequenceif len(response.split()) > 50: # Prevent long explanationsresponse = """1. Think about how the animal is typically associated with a specific characteristic, such as color, habitat, or shape.2. Consider how the fruit shares a similar characteristic or feature with the animal.3. Finally, think about the color that ties both the animal and the fruit together."""yield response1 unmodified linedemo = gr.ChatInterface(respond,additional_inputs=[gr.Textbox(value="You are a chatbot that helps users think through the connections between an animal, a fruit, and a color. Provide reasoning and clues, but do not reveal 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(8 unmodified linesif __name__ == "__main__":demo.launch()18 unmodified lines1920212223242526272829303132333411 unmodified lines4647484950515253541 unmodified line565758596061628 unmodified lines71727318 unmodified linesif val[1]:messages.append({"role": "assistant", "content": val[1]})# Modify the prompt to make the clues specific to each sequence (no generic format)formatted_prompt = f"""You are a chatbot that helps users think through the connections between an animal, a fruit, and a color.For each sequence, provide clues based on the specific animal, fruit, and color mentioned. Do not give away the final answer.1. For the animal, provide clues related to its unique characteristics (e.g., its size, habitat, or color).2. For the fruit, provide clues that relate to how it shares a feature with the animal (e.g., color, texture, shape, or taste).3. For the color, provide clues about why this color ties both the animal and the fruit together.Focus on generating unique reasoning for each specific input and make the clues related to the particular animal, fruit, and color.Now, help me think through this sequence: "{message}""""11 unmodified linestoken = message.choices[0].delta.contentresponse += token# Limit the response to dynamic reasoning and avoid repeating the same structureif len(response.split()) > 50: # Prevent long explanationsresponse = response.strip()yield response1 unmodified linedemo = gr.ChatInterface(respond,additional_inputs=[gr.Textbox(value="You are a chatbot that helps users think creatively through sequences of words. Provide reasoning and clues, but do not reveal 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(8 unmodified linesif __name__ == "__main__":demo.launch()
app.py+10-16