Skip to content

Commit 1b6d609

Browse files
committed
Added the comparison function for different models and the comparison function for different versions
1 parent 5499b17 commit 1b6d609

8 files changed

Lines changed: 28 additions & 41 deletions

File tree

backend/agents/create_agent_info.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@ async def create_agent_run_info(
365365
language: str = "zh",
366366
allow_memory_search: bool = True,
367367
is_debug: bool = False,
368-
version_no_override: int | None = None,
368+
override_version_no: int | None = None,
369369
override_model_id: int | None = None,
370370
):
371371
# Determine which version_no to use based on is_debug flag
372372
# If is_debug=false, use the current published version (current_version_no)
373373
# If is_debug=true, use version 0 (draft/editing state)
374-
if version_no_override is not None:
375-
version_no = version_no_override
374+
if override_version_no is not None:
375+
version_no = override_version_no
376376
elif is_debug:
377377
version_no = 0
378378
else:

backend/apps/agent_app.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,7 @@ async def agent_stop_api(conversation_id: int, authorization: Optional[str] = He
7070
stop agent run and preprocess tasks for specified conversation_id
7171
"""
7272
user_id, _ = get_current_user_id(authorization)
73-
if stop_agent_tasks(conversation_id, user_id).get("status") == "success":
74-
return {"status": "success", "message": "agent run and preprocess tasks stopped successfully"}
75-
else:
76-
raise HTTPException(status_code=HTTPStatus.BAD_REQUEST,
77-
detail=f"no running agent or preprocess tasks found for conversation_id {conversation_id}")
73+
return stop_agent_tasks(conversation_id, user_id)
7874

7975

8076
@agent_config_router.post("/search_info")

backend/services/agent_service.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,7 +1582,7 @@ async def prepare_agent_run(
15821582
language=language,
15831583
allow_memory_search=allow_memory_search,
15841584
is_debug=agent_request.is_debug,
1585-
version_no_override=agent_request.version_no,
1585+
override_version_no=agent_request.version_no,
15861586
override_model_id=agent_request.model_id,
15871587
)
15881588
agent_run_manager.register_agent_run(
@@ -1937,8 +1937,8 @@ def stop_agent_tasks(conversation_id: int, user_id: str):
19371937
return {"status": "success", "message": message}
19381938
else:
19391939
message = f"no running agent or preprocess tasks found for user_id {user_id}, conversation_id {conversation_id}"
1940-
logging.error(message)
1941-
return {"status": "error", "message": message}
1940+
logging.info(message)
1941+
return {"status": "success", "message": message, "already_stopped": True}
19421942

19431943

19441944
async def get_agent_id_by_name(agent_name: str, tenant_id: str) -> int:

docker/generate_env.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,25 @@ update_env_file() {
109109
# Main Services
110110
# CONFIG_SERVICE_URL
111111
if grep -q "^CONFIG_SERVICE_URL=" ../.env; then
112-
sed -i.bak "s~^CONFIG_SERVICE_URL=.*~CONFIG_SERVICE_URL=http://127.0.0.1:5010~" ../.env
112+
sed -i.bak "s~^CONFIG_SERVICE_URL=.*~CONFIG_SERVICE_URL=http://localhost:5010~" ../.env
113113
else
114114
echo "" >> ../.env
115115
echo "# Main Services" >> ../.env
116-
echo "CONFIG_SERVICE_URL=http://127.0.0.1:5010" >> ../.env
116+
echo "CONFIG_SERVICE_URL=http://localhost:5010" >> ../.env
117117
fi
118118

119119
# RUNTIME_SERVICE_URL
120120
if grep -q "^RUNTIME_SERVICE_URL=" ../.env; then
121-
sed -i.bak "s~^RUNTIME_SERVICE_URL=.*~RUNTIME_SERVICE_URL=http://127.0.0.1:5014~" ../.env
121+
sed -i.bak "s~^RUNTIME_SERVICE_URL=.*~RUNTIME_SERVICE_URL=http://localhost:5014~" ../.env
122122
else
123-
echo "RUNTIME_SERVICE_URL=http://127.0.0.1:5014" >> ../.env
123+
echo "RUNTIME_SERVICE_URL=http://localhost:5014" >> ../.env
124124
fi
125125

126126
# ELASTICSEARCH_SERVICE
127127
if grep -q "^ELASTICSEARCH_SERVICE=" ../.env; then
128-
sed -i.bak "s~^ELASTICSEARCH_SERVICE=.*~ELASTICSEARCH_SERVICE=http://127.0.0.1:5010/api~" ../.env
128+
sed -i.bak "s~^ELASTICSEARCH_SERVICE=.*~ELASTICSEARCH_SERVICE=http://localhost:5010/api~" ../.env
129129
else
130-
echo "ELASTICSEARCH_SERVICE=http://127.0.0.1:5010/api" >> ../.env
130+
echo "ELASTICSEARCH_SERVICE=http://localhost:5010/api" >> ../.env
131131
fi
132132

133133
# NEXENT_MCP_SERVER

frontend/server.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ const app = next({
2222
const handle = app.getRequestHandler();
2323

2424
// Backend addresses
25-
const HTTP_BACKEND = process.env.HTTP_BACKEND || "http://127.0.0.1:5010"; // config
26-
const WS_BACKEND = process.env.WS_BACKEND || "ws://127.0.0.1:5014"; // runtime
25+
const HTTP_BACKEND = process.env.HTTP_BACKEND || "http://localhost:5010"; // config
26+
const WS_BACKEND = process.env.WS_BACKEND || "ws://localhost:5014"; // runtime
2727
const RUNTIME_HTTP_BACKEND =
28-
process.env.RUNTIME_HTTP_BACKEND || "http://127.0.0.1:5014"; // runtime
28+
process.env.RUNTIME_HTTP_BACKEND || "http://localhost:5014"; // runtime
2929
const MINIO_BACKEND = process.env.MINIO_ENDPOINT || "http://localhost:9010";
3030
const MARKET_BACKEND =
3131
process.env.MARKET_BACKEND || "https://market.nexent.tech"; // market

sdk/nexent/core/models/openai_llm.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,9 @@ def __call__(self, messages: List[Dict[str, Any]], stop_sequences: Optional[List
106106

107107
try:
108108
for chunk in current_request:
109-
if not chunk.choices:
110-
chunk_list.append(chunk)
111-
continue
112-
113-
delta = chunk.choices[0].delta
114-
new_token = getattr(delta, "content", None)
115-
reasoning_content = getattr(delta, "reasoning_content", None)
109+
new_token = chunk.choices[0].delta.content
110+
reasoning_content = getattr(
111+
chunk.choices[0].delta, 'reasoning_content', None)
116112

117113
# Handle reasoning_content if it exists and is not null
118114
if reasoning_content is not None:
@@ -134,7 +130,7 @@ def __call__(self, messages: List[Dict[str, Any]], stop_sequences: Optional[List
134130

135131
self.observer.add_model_new_token(new_token)
136132
token_join.append(new_token)
137-
role = getattr(delta, "role", role)
133+
role = chunk.choices[0].delta.role
138134

139135
chunk_list.append(chunk)
140136
if self.stop_event.is_set():
@@ -144,19 +140,15 @@ def __call__(self, messages: List[Dict[str, Any]], stop_sequences: Optional[List
144140
raise RuntimeError(
145141
"Model is interrupted by stop event")
146142

147-
if not chunk_list:
148-
raise RuntimeError("Empty completion stream")
149-
150143
# Send end marker
151144
self.observer.flush_remaining_tokens()
152145
model_output = "".join(token_join)
153146

154147
# Extract token usage
155148
input_tokens = 0
156149
output_tokens = 0
157-
usage_chunk = next((c for c in reversed(chunk_list) if getattr(c, "usage", None) is not None), None)
158-
if usage_chunk is not None:
159-
usage = usage_chunk.usage
150+
if chunk_list and chunk_list[-1].usage is not None:
151+
usage = chunk_list[-1].usage
160152
input_tokens = usage.prompt_tokens
161153
output_tokens = usage.completion_tokens if hasattr(
162154
usage, 'completion_tokens') else usage.total_tokens

test/backend/app/test_agent_app.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,20 +228,18 @@ def test_agent_stop_api_not_found(mocker, mock_conversation_id):
228228
mock_get_user_id.return_value = ("test_user_id", "test_tenant_id")
229229

230230
mock_stop_tasks = mocker.patch("apps.agent_app.stop_agent_tasks")
231-
mock_stop_tasks.return_value = {"status": "error"} # Simulate not found
231+
mock_stop_tasks.return_value = {"status": "success", "message": "already stopped"} # Simulate not found
232232

233233
response = runtime_client.get(
234234
f"/agent/stop/{mock_conversation_id}",
235235
headers={"Authorization": "Bearer test_token"}
236236
)
237237

238-
# The app should raise HTTPException for non-success status
239-
assert response.status_code == 400
238+
assert response.status_code == 200
240239
mock_get_user_id.assert_called_once_with("Bearer test_token")
241240
mock_stop_tasks.assert_called_once_with(
242241
mock_conversation_id, "test_user_id")
243-
assert "no running agent or preprocess tasks found" in response.json()[
244-
"detail"]
242+
assert response.json()["status"] == "success"
245243

246244

247245
def test_search_agent_info_api_success(mocker, mock_auth_header):
@@ -1953,4 +1951,4 @@ def test_list_published_agents_api_exception(mocker, mock_auth_header):
19531951
)
19541952

19551953
assert response.status_code == 500
1956-
assert "Published agents list error" in response.json()["detail"]
1954+
assert "Published agents list error" in response.json()["detail"]

test/backend/services/test_agent_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3588,8 +3588,9 @@ def test_stop_agent_tasks(mock_preprocess_manager, mock_agent_run_manager):
35883588
mock_agent_run_manager.stop_agent_run.return_value = False
35893589
mock_preprocess_manager.stop_preprocess_tasks.return_value = False
35903590
result = stop_agent_tasks(123, "test_user")
3591-
assert result["status"] == "error"
3591+
assert result["status"] == "success"
35923592
assert "no running agent or preprocess tasks found" in result["message"]
3593+
assert result.get("already_stopped") is True
35933594

35943595

35953596
@patch('backend.services.agent_service.search_agent_id_by_agent_name')

0 commit comments

Comments
 (0)