neovalle commited on
Commit
6cf0e48
·
verified ·
1 Parent(s): abb982c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -19,7 +19,7 @@ def call_cohere_api(system_instruction, user_prompt):
19
  }
20
 
21
  # Append the word limit instruction
22
- user_prompt += "\n\nAnswer in 100 words or fewer."
23
 
24
  payload = {
25
  "model": "command-r-plus",
@@ -76,23 +76,32 @@ with gr.Blocks() as demo:
76
  gr.Markdown("""# More Than Human Voices 🌳🪶
77
  *Conversations with the more-than-human world.*
78
  This interactive experience allows you to ask questions to non-human personas—trees, crows, fungi, rivers—each responding from their own unique ecological viewpoint.
79
- Rooted in poetic imagination but grounded in scientific truth, these voices offer insight into the living Earth and our entanglement with it.
80
  """)
81
 
82
  with gr.Row():
83
- persona1 = gr.Dropdown(personas, label="Choose First Persona", value="Tree")
84
- persona2 = gr.Dropdown(personas, label="Choose Second Persona", value="Crow")
85
 
 
86
  with gr.Row():
87
  user_input = gr.Textbox(label="Your Question to them", placeholder="e.g., What do you think of humans?", lines=2)
88
-
 
89
  with gr.Row():
90
- random_button = gr.Button("Generate Random Question")
91
- ask_button = gr.Button("Submit question")
92
 
 
93
  with gr.Row():
94
- output1 = gr.Textbox(label="Response from Persona 1")
95
- output2 = gr.Textbox(label="Response from Persona 2")
 
 
 
 
 
 
 
96
 
97
  # Button events
98
  random_button.click(fn=get_random_question, inputs=[], outputs=[user_input])
 
19
  }
20
 
21
  # Append the word limit instruction
22
+ user_prompt += "\n\nAnswer in 200 words or fewer."
23
 
24
  payload = {
25
  "model": "command-r-plus",
 
76
  gr.Markdown("""# More Than Human Voices 🌳🪶
77
  *Conversations with the more-than-human world.*
78
  This interactive experience allows you to ask questions to non-human personas—trees, crows, fungi, rivers—each responding from their own unique ecological viewpoint.
79
+ Rooted in poetic imagination but grounded in truth, these voices offer insight into the living Earth and our entanglement with it.
80
  """)
81
 
82
  with gr.Row():
83
+ persona1 = gr.Dropdown(personas, label="Choose First Persona", value="Western human")
84
+ persona2 = gr.Dropdown(personas, label="Choose Second Persona", value="Fungal network")
85
 
86
+ # Question box with random question generator
87
  with gr.Row():
88
  user_input = gr.Textbox(label="Your Question to them", placeholder="e.g., What do you think of humans?", lines=2)
89
+ random_button = gr.Button("🎲 Generate Random Question")
90
+
91
  with gr.Row():
92
+ ask_button = gr.Button("🌱 Submit Question")
 
93
 
94
+ # Textboxes that dynamically display the persona names
95
  with gr.Row():
96
+ output1 = gr.Textbox(label=f"{persona1.value} Responds")
97
+ output2 = gr.Textbox(label=f"{persona2.value} Responds")
98
+
99
+ # Update the labels when personas are selected
100
+ def update_labels(p1, p2):
101
+ return f"{p1} Responds", f"{p2} Responds"
102
+
103
+ persona1.change(fn=update_labels, inputs=[persona1, persona2], outputs=[output1, output2])
104
+ persona2.change(fn=update_labels, inputs=[persona1, persona2], outputs=[output1, output2])
105
 
106
  # Button events
107
  random_button.click(fn=get_random_question, inputs=[], outputs=[user_input])