Spaces:
Sleeping
Sleeping
Update ui/contentagentui.py
Browse files- ui/contentagentui.py +25 -10
ui/contentagentui.py
CHANGED
|
@@ -14,11 +14,13 @@ class ContentAgentUI:
|
|
| 14 |
- reveals the main chat panel (with header, guidance, examples, footer) after init.
|
| 15 |
"""
|
| 16 |
|
| 17 |
-
def __init__(self, endpoint_uri: str, is_healthy: bool, health_message: str, agent_initializer):
|
| 18 |
self.endpoint_uri = endpoint_uri
|
| 19 |
self.is_healthy = bool(is_healthy)
|
| 20 |
self.health_message = health_message or ""
|
| 21 |
self.agent_initializer = agent_initializer # callable: (uri) -> CodeAgent
|
|
|
|
|
|
|
| 22 |
|
| 23 |
# set in build()
|
| 24 |
self.app: gr.Blocks | None = None
|
|
@@ -29,24 +31,36 @@ class ContentAgentUI:
|
|
| 29 |
self.reply = None
|
| 30 |
self.agent_state = None
|
| 31 |
self.examples_radio = None
|
|
|
|
|
|
|
| 32 |
|
| 33 |
# ---------- helpers ----------
|
| 34 |
|
| 35 |
|
|
|
|
| 36 |
def _create_user_guidance(self):
|
|
|
|
|
|
|
| 37 |
gr.Markdown("""
|
| 38 |
Please enter text below to get started. Content Agent will try to determine whether the language is polite and uses the following classification:
|
| 39 |
- `polite`
|
| 40 |
- `somewhat polite`
|
| 41 |
- `neutral`
|
| 42 |
- `impolite`
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
def _get_css(self) -> str | None:
|
|
@@ -90,7 +104,7 @@ class ContentAgentUI:
|
|
| 90 |
def _call_agent(text: str, agent) -> str:
|
| 91 |
try:
|
| 92 |
if agent is None:
|
| 93 |
-
return "
|
| 94 |
return str(agent.run(text)) # smolagents.CodeAgent API
|
| 95 |
except Exception as e:
|
| 96 |
return f"Error: {e}"
|
|
@@ -117,7 +131,8 @@ class ContentAgentUI:
|
|
| 117 |
lines=8,
|
| 118 |
interactive=False,
|
| 119 |
)
|
| 120 |
-
start_btn = gr.Button("Start Agent
|
|
|
|
| 121 |
|
| 122 |
|
| 123 |
# Main panel (hidden until agent is initialized)
|
|
|
|
| 14 |
- reveals the main chat panel (with header, guidance, examples, footer) after init.
|
| 15 |
"""
|
| 16 |
|
| 17 |
+
def __init__(self, endpoint_uri: str, is_healthy: bool, health_message: str, agent_initializer, agent_type:str, compute:str ):
|
| 18 |
self.endpoint_uri = endpoint_uri
|
| 19 |
self.is_healthy = bool(is_healthy)
|
| 20 |
self.health_message = health_message or ""
|
| 21 |
self.agent_initializer = agent_initializer # callable: (uri) -> CodeAgent
|
| 22 |
+
self.agenttype = agenttype or ""
|
| 23 |
+
self.compute = compute or ""
|
| 24 |
|
| 25 |
# set in build()
|
| 26 |
self.app: gr.Blocks | None = None
|
|
|
|
| 31 |
self.reply = None
|
| 32 |
self.agent_state = None
|
| 33 |
self.examples_radio = None
|
| 34 |
+
|
| 35 |
+
|
| 36 |
|
| 37 |
# ---------- helpers ----------
|
| 38 |
|
| 39 |
|
| 40 |
+
|
| 41 |
def _create_user_guidance(self):
|
| 42 |
+
|
| 43 |
+
|
| 44 |
gr.Markdown("""
|
| 45 |
Please enter text below to get started. Content Agent will try to determine whether the language is polite and uses the following classification:
|
| 46 |
- `polite`
|
| 47 |
- `somewhat polite`
|
| 48 |
- `neutral`
|
| 49 |
- `impolite`
|
| 50 |
+
|
| 51 |
+
Classificiation Scores
|
| 52 |
+
- Scoring runs from O to 1
|
| 53 |
+
|
| 54 |
+
""")
|
| 55 |
+
|
| 56 |
+
# gr.Markdown ("""
|
| 57 |
+
# Technology:
|
| 58 |
+
# - App is running `deepseek-ai/DeepSeek-R1-Distill-Qwen-32B` text generation model.
|
| 59 |
+
# - Agent uses Intel's Polite Guard NLP library tool
|
| 60 |
+
# - Compute: GCP · Nvidia L4 · 4x GPUs · 96 GB
|
| 61 |
+
# - Content Agents's LLM runs on-demand rather than using resources for 24 hrs/day, 7 days a week
|
| 62 |
+
#
|
| 63 |
+
# """)
|
| 64 |
|
| 65 |
|
| 66 |
def _get_css(self) -> str | None:
|
|
|
|
| 104 |
def _call_agent(text: str, agent) -> str:
|
| 105 |
try:
|
| 106 |
if agent is None:
|
| 107 |
+
return "Content Agent's LLM is sleeping and will need to be started. Click 'Start Agent'."
|
| 108 |
return str(agent.run(text)) # smolagents.CodeAgent API
|
| 109 |
except Exception as e:
|
| 110 |
return f"Error: {e}"
|
|
|
|
| 131 |
lines=8,
|
| 132 |
interactive=False,
|
| 133 |
)
|
| 134 |
+
start_btn = gr.Button("Start Agent")
|
| 135 |
+
gr.Markdown("It may take up to 5 minutes to wake up the agent"
|
| 136 |
|
| 137 |
|
| 138 |
# Main panel (hidden until agent is initialized)
|