Spaces:
Running
Running
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -124,9 +124,11 @@ def chat_respond(message, history):
|
|
| 124 |
prose, trace, gov_dict, commitment = _generate_one(temperature=0.7)
|
| 125 |
|
| 126 |
if prose is None:
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
# Build compact trace display
|
| 130 |
g_ops = trace["gov_structure"]["G"]
|
| 131 |
s_ops = trace["gov_structure"]["S"]
|
| 132 |
f_ops = trace["gov_structure"]["F"]
|
|
@@ -136,10 +138,13 @@ def chat_respond(message, history):
|
|
| 136 |
f"Gates: 7/7 | Witnesses: 7/7 | Committed: {trace['commitment'][:16]}..."
|
| 137 |
)
|
| 138 |
|
| 139 |
-
# Response with governance annotation
|
| 140 |
response = f"{prose}\n\n---\n*Governance: {trace_display}*"
|
| 141 |
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
|
| 145 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -268,7 +273,6 @@ def verify_governance(output_text, trace_json_str):
|
|
| 268 |
|
| 269 |
with gr.Blocks(
|
| 270 |
title="Axiom: Governed Language Model",
|
| 271 |
-
theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"),
|
| 272 |
) as app:
|
| 273 |
|
| 274 |
gr.Markdown("""
|
|
@@ -287,7 +291,6 @@ with gr.Blocks(
|
|
| 287 |
chatbot = gr.Chatbot(
|
| 288 |
label="Axiom",
|
| 289 |
height=400,
|
| 290 |
-
type="tuples",
|
| 291 |
)
|
| 292 |
msg = gr.Textbox(
|
| 293 |
label="Message",
|
|
@@ -314,7 +317,7 @@ with gr.Blocks(
|
|
| 314 |
outputs=[chatbot, chat_trace],
|
| 315 |
).then(lambda: "", outputs=msg)
|
| 316 |
|
| 317 |
-
clear_btn.click(lambda: (
|
| 318 |
|
| 319 |
# ββ Tab 2: Generate ββ
|
| 320 |
with gr.Tab("Generate"):
|
|
@@ -368,4 +371,4 @@ with gr.Blocks(
|
|
| 368 |
""")
|
| 369 |
|
| 370 |
if __name__ == "__main__":
|
| 371 |
-
app.launch()
|
|
|
|
| 124 |
prose, trace, gov_dict, commitment = _generate_one(temperature=0.7)
|
| 125 |
|
| 126 |
if prose is None:
|
| 127 |
+
history = history or []
|
| 128 |
+
history.append({"role": "user", "content": message})
|
| 129 |
+
history.append({"role": "assistant", "content": "Governance pipeline did not admit a candidate. Try again."})
|
| 130 |
+
return history, ""
|
| 131 |
|
|
|
|
| 132 |
g_ops = trace["gov_structure"]["G"]
|
| 133 |
s_ops = trace["gov_structure"]["S"]
|
| 134 |
f_ops = trace["gov_structure"]["F"]
|
|
|
|
| 138 |
f"Gates: 7/7 | Witnesses: 7/7 | Committed: {trace['commitment'][:16]}..."
|
| 139 |
)
|
| 140 |
|
|
|
|
| 141 |
response = f"{prose}\n\n---\n*Governance: {trace_display}*"
|
| 142 |
|
| 143 |
+
history = history or []
|
| 144 |
+
history.append({"role": "user", "content": message})
|
| 145 |
+
history.append({"role": "assistant", "content": response})
|
| 146 |
+
|
| 147 |
+
return history, json.dumps(trace, indent=2)
|
| 148 |
|
| 149 |
|
| 150 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 273 |
|
| 274 |
with gr.Blocks(
|
| 275 |
title="Axiom: Governed Language Model",
|
|
|
|
| 276 |
) as app:
|
| 277 |
|
| 278 |
gr.Markdown("""
|
|
|
|
| 291 |
chatbot = gr.Chatbot(
|
| 292 |
label="Axiom",
|
| 293 |
height=400,
|
|
|
|
| 294 |
)
|
| 295 |
msg = gr.Textbox(
|
| 296 |
label="Message",
|
|
|
|
| 317 |
outputs=[chatbot, chat_trace],
|
| 318 |
).then(lambda: "", outputs=msg)
|
| 319 |
|
| 320 |
+
clear_btn.click(lambda: (None, ""), outputs=[chatbot, chat_trace])
|
| 321 |
|
| 322 |
# ββ Tab 2: Generate ββ
|
| 323 |
with gr.Tab("Generate"):
|
|
|
|
| 371 |
""")
|
| 372 |
|
| 373 |
if __name__ == "__main__":
|
| 374 |
+
app.launch(theme=gr.themes.Base(primary_hue="green", neutral_hue="slate"))
|