Spaces:
Sleeping
Sleeping
Update app.py
Browse files18 unmodified lines19202122232425262728293031323334353637388 unmodified lines4748495051525354551 unmodified line5758596061626310 unmodified lines74757618 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(10 unmodified linesdemo.launch()18 unmodified lines192021222324252627282930313233343536378 unmodified lines464748495051525354555657581 unmodified line6061626364656610 unmodified lines7778798018 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})response = ""8 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 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(10 unmodified linesdemo.launch()
app.py+16-12