mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 13:52:43 +08:00
Fix issue #3913: Show rate limit issues in the UI
This commit is contained in:
parent
8059e8e298
commit
f194fe8b95
@ -20,9 +20,13 @@ function AgentStatusBar() {
|
||||
const { curAgentState } = useSelector((state: RootState) => state.agent);
|
||||
const { curStatusMessage } = useSelector((state: RootState) => state.status);
|
||||
|
||||
const AgentStatusMap: {
|
||||
const AgentStatusMap: {
|
||||
[k: string]: { message: string; indicator: IndicatorColor };
|
||||
} = {
|
||||
[AgentState.RATE_LIMITED]: {
|
||||
message: t(I18nKey.AGENT_STATUS$RATE_LIMITED_MESSAGE),
|
||||
indicator: IndicatorColor.YELLOW,
|
||||
},
|
||||
[AgentState.INIT]: {
|
||||
message: t(I18nKey.CHAT_INTERFACE$AGENT_INIT_MESSAGE),
|
||||
indicator: IndicatorColor.BLUE,
|
||||
|
||||
@ -1,4 +1,18 @@
|
||||
{
|
||||
"AGENT_STATUS$RATE_LIMITED_MESSAGE": {
|
||||
"en": "Agent is rate limited. Please wait.",
|
||||
"zh-CN": "代理已达到速率限制。请稍候。",
|
||||
"de": "Agent ist ratenbegrenzt. Bitte warten.",
|
||||
"ko-KR": "에이전트가 속도 제한되었습니다. 잠시만 기다려주세요.",
|
||||
"no": "Agenten er hastighetsbegrenset. Vennligst vent.",
|
||||
"zh-TW": "代理已達到速率限制。請稍候。",
|
||||
"it": "L'agente è limitato dalla velocità. Attendere prego.",
|
||||
"pt": "O agente está com limite de taxa. Por favor, aguarde.",
|
||||
"es": "El agente está limitado por tasa. Por favor, espere.",
|
||||
"ar": "الوكيل محدود بمعدل. يرجى الانتظار.",
|
||||
"fr": "L'agent est limité en débit. Veuillez patienter.",
|
||||
"tr": "Ajan hız sınırlamasına tabi. Lütfen bekleyin."
|
||||
},
|
||||
"WORKSPACE$TITLE": {
|
||||
"en": "OpenHands Workspace",
|
||||
"zh-CN": "OpenHands 工作区",
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
enum AgentState {
|
||||
RATE_LIMITED = "rate_limited",
|
||||
LOADING = "loading",
|
||||
INIT = "init",
|
||||
RUNNING = "running",
|
||||
|
||||
@ -500,7 +500,7 @@ class AgentController:
|
||||
self.event_stream.add_event(obs, EventSource.AGENT)
|
||||
return
|
||||
|
||||
async def _handle_traffic_control(
|
||||
async def _handle_traffic_control(
|
||||
self, limit_type: str, current_value: float, max_value: float
|
||||
):
|
||||
"""Handles agent state after hitting the traffic control limit.
|
||||
@ -511,6 +511,8 @@ class AgentController:
|
||||
max_value (float): The maximum value of the limit.
|
||||
"""
|
||||
stop_step = False
|
||||
self.state.agent_state = AgentState.RATE_LIMITED
|
||||
await self._publish_agent_state_changed()
|
||||
if self.state.traffic_control_state == TrafficControlState.PAUSED:
|
||||
logger.info('Hitting traffic control, temporarily resume upon user request')
|
||||
self.state.traffic_control_state = TrafficControlState.NORMAL
|
||||
|
||||
@ -6,6 +6,10 @@ class AgentState(str, Enum):
|
||||
"""The agent is loading.
|
||||
"""
|
||||
|
||||
RATE_LIMITED = 'rate_limited'
|
||||
"""The agent is rate limited.
|
||||
"""
|
||||
|
||||
INIT = 'init'
|
||||
"""The agent is initialized.
|
||||
"""
|
||||
|
||||
2
poetry.lock
generated
2
poetry.lock
generated
@ -9685,4 +9685,4 @@ testing = ["coverage (>=5.0.3)", "zope.event", "zope.testing"]
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "78e09d0b5c33f39ec951659658b5b4b46ba206d8f95e9a154be4e0ef869b7c79"
|
||||
content-hash = "1e4da073f36492c1db18dc0134a2f13746519bd529abc6a54dea579c4f89b260"
|
||||
|
||||
@ -54,6 +54,7 @@ python-pptx = "*"
|
||||
pylatexenc = "*"
|
||||
tornado = "*"
|
||||
python-dotenv = "*"
|
||||
pytest = "^8.3.3"
|
||||
|
||||
[tool.poetry.group.llama-index.dependencies]
|
||||
llama-index = "*"
|
||||
@ -85,6 +86,7 @@ reportlab = "*"
|
||||
[tool.coverage.run]
|
||||
concurrency = ["gevent"]
|
||||
|
||||
|
||||
[tool.poetry.group.runtime.dependencies]
|
||||
jupyterlab = "*"
|
||||
notebook = "*"
|
||||
@ -115,6 +117,7 @@ ignore = ["D1"]
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
convention = "google"
|
||||
|
||||
|
||||
[tool.poetry.group.evaluation.dependencies]
|
||||
streamlit = "*"
|
||||
whatthepatch = "*"
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
import pytest
|
||||
|
||||
from agenthub.micro.agent import parse_response as parse_response_micro
|
||||
from agenthub.planner_agent.prompt import parse_response as parse_response_planner
|
||||
from openhands.core.exceptions import LLMResponseError
|
||||
from openhands.core.utils.json import loads as custom_loads
|
||||
from openhands.events.action import (
|
||||
@ -9,10 +7,12 @@ from openhands.events.action import (
|
||||
MessageAction,
|
||||
)
|
||||
|
||||
# TODO: Replace this with the correct import for parse_response
|
||||
from openhands.utils.microagent import parse_response
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'parse_response_module',
|
||||
[parse_response_micro, parse_response_planner],
|
||||
[parse_response],
|
||||
)
|
||||
def test_parse_single_complete_json(parse_response_module):
|
||||
input_response = """
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user