Spaces:
Sleeping
Sleeping
Update app.py
Browse files18 unmodified lines192021222324252627282930313233343510 unmodified lines4647484950515253545556572 unmodified lines6061626364656618 unmodified linesif val[1]:messages.append({"role": "assistant", "content": val[1]})# Generalize the reasoning for any input without focusing on specific examplesformatted_prompt = f"""You are a chatbot that helps users think creatively through sequences of words.For each word in the sequence, provide reasoning without directly revealing the final sequence:1. Think of an animal that shares a common characteristic related to the first word.2. Consider a fruit that shares this same characteristic.3. Describe a color that can be associated with both the animal and fruit.Do NOT give away the final sequence directly. Offer clues that guide the user toward the connection between the words.Now, help me think through this sequence: "{message}""""messages.append({"role": "user", "content": formatted_prompt})10 unmodified linestoken = message.choices[0].delta.contentresponse += token# Limit the response to just reasoning and clues, without revealing the answerif len(response.split()) > 50: # Prevent long explanationsresponse = """1. Think of an animal that shares a common characteristic related to the first word.2. Now, consider a fruit that shares the same characteristic.3. Finally, describe a color that connects both the animal and fruit."""yield response2 unmodified linesdemo = 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(18 unmodified lines192021222324252627282930313233343510 unmodified lines4647484950515253545556572 unmodified lines6061626364656618 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}""""messages.append({"role": "user", "content": formatted_prompt})10 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 response2 unmodified linesdemo = 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(
app.py+13-13