spanofzero commited on
Commit
c569764
·
verified ·
1 Parent(s): 836f78e

fastestest

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -28,7 +28,6 @@ class StateController:
28
 
29
  def diagnostic(self) -> str:
30
  """Execute diagnostic sequence and return the formatted status report."""
31
- # Update state array for diagnostic verification
32
  for i in range(51):
33
  self._state[i] = i % self._batch
34
 
@@ -47,12 +46,12 @@ class StateController:
47
  # Global singleton instance for resource reuse
48
  controller = StateController()
49
 
50
- SYSTEM_MSG = [
51
- {"role": "system",
52
- "content": ("You are a logic-focused inference engine. "
53
- "Utilize strict state-hold memory and parallel integer blocks. "
54
- "Provide direct, technical, and accurate responses.")}
55
- ]
56
 
57
  def generate_response(message: str, history: list):
58
  # Hardware diagnostic override
@@ -60,12 +59,12 @@ def generate_response(message: str, history: list):
60
  yield controller.diagnostic()
61
  return
62
 
63
- # Utilize Gradio history directly to avoid redundant list processing
64
- messages = SYSTEM_MSG + [
65
- {"role": "user", "content": turn[0]},
66
- {"role": "assistant", "content": turn[1]}
67
- for turn in history
68
- ] + [{"role": "user", "content": message}]
69
 
70
  try:
71
  # Enable streaming for reduced time-to-first-token
@@ -104,5 +103,4 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue="blue"), css=custom_css) as demo
104
  )
105
 
106
  if __name__ == "__main__":
107
- # Launch with queue enabled for streaming support
108
  demo.queue().launch(show_api=False)
 
28
 
29
  def diagnostic(self) -> str:
30
  """Execute diagnostic sequence and return the formatted status report."""
 
31
  for i in range(51):
32
  self._state[i] = i % self._batch
33
 
 
46
  # Global singleton instance for resource reuse
47
  controller = StateController()
48
 
49
+ SYSTEM_MSG = {
50
+ "role": "system",
51
+ "content": ("You are a logic-focused inference engine. "
52
+ "Utilize strict state-hold memory and parallel integer blocks. "
53
+ "Provide direct, technical, and accurate responses.")
54
+ }
55
 
56
  def generate_response(message: str, history: list):
57
  # Hardware diagnostic override
 
59
  yield controller.diagnostic()
60
  return
61
 
62
+ # Build the message list using a standard loop to ensure syntax stability
63
+ messages = [SYSTEM_MSG]
64
+ for turn in history:
65
+ messages.append({"role": "user", "content": turn[0]})
66
+ messages.append({"role": "assistant", "content": turn[1]})
67
+ messages.append({"role": "user", "content": message})
68
 
69
  try:
70
  # Enable streaming for reduced time-to-first-token
 
103
  )
104
 
105
  if __name__ == "__main__":
 
106
  demo.queue().launch(show_api=False)