mriusero commited on
Commit
60ed03c
·
1 Parent(s): 698ce3e

core: safety

Browse files
src/agent/stream.py CHANGED
@@ -32,7 +32,8 @@ async def respond(message, history=None):
32
  if history is None:
33
  history = []
34
 
35
- history.append(ChatMessage(role="assistant", content="", metadata={"title": "Thinking...", "status": "pending"}))
 
36
  yield history
37
 
38
  messages = [
@@ -131,7 +132,7 @@ async def respond(message, history=None):
131
  messages = call_tool(
132
  agent,
133
  tool_calls,
134
- messages
135
  )
136
  last_tool_response = next((m for m in reversed(messages) if m["role"] == "tool"), None)
137
  if last_tool_response and last_tool_response.get("content"):
 
32
  if history is None:
33
  history = []
34
 
35
+ if not history or history[-1].role != "assistant" or history[-1].metadata.get("status") == "done":
36
+ history.append(ChatMessage(role="assistant", content="", metadata={"title": "Thinking...", "status": "pending"}))
37
  yield history
38
 
39
  messages = [
 
132
  messages = call_tool(
133
  agent,
134
  tool_calls,
135
+ messages,
136
  )
137
  last_tool_response = next((m for m in reversed(messages) if m["role"] == "tool"), None)
138
  if last_tool_response and last_tool_response.get("content"):
src/agent/tools/check_production.py ADDED
File without changes
src/ui/sidebar.py CHANGED
@@ -49,10 +49,11 @@ def sidebar_ui(state, width=700, visible=True):
49
  # ["How do I troubleshoot a specific piece of equipment?"],
50
  # ["What are the best practices for maintaining production efficiency?"]
51
  ],
 
52
  cache_examples=False # désactive le cache si les réponses varient
53
  )
54
- with gr.TabItem("Documentation", visible=True):
55
- md_output = gr.Markdown("📄 La documentation s'affichera ici.")
56
 
57
  #textbox=gr.MultimodalTextbox(file_types=[".png", ".pdf"], sources=["upload", "microphone"]),
58
  #additional_inputs=[gr.Textbox("Système", label="System prompt"), gr.Slider(0, 1)],
 
49
  # ["How do I troubleshoot a specific piece of equipment?"],
50
  # ["What are the best practices for maintaining production efficiency?"]
51
  ],
52
+ # additional_inputs=[state],
53
  cache_examples=False # désactive le cache si les réponses varient
54
  )
55
+ #with gr.TabItem("Documentation", visible=True):
56
+ # md_output = gr.Markdown("📄 La documentation s'affichera ici.")
57
 
58
  #textbox=gr.MultimodalTextbox(file_types=[".png", ".pdf"], sources=["upload", "microphone"]),
59
  #additional_inputs=[gr.Textbox("Système", label="System prompt"), gr.Slider(0, 1)],