mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-06 15:21:13 +02:00
style: fix E501 line-too-long errors in gns3_copilot
Fix all 423 E501 line length violations across 26 files to comply with
PEP 8 88-character line limit.
Changes:
- Split long f-strings across multiple lines
- Break long docstring descriptions and parameter lists
- Split markdown table rows and list examples
- Break long URL construction f-strings
- Split long logger messages and comments
- Add noqa: E501 for SVG strings (cannot be split)
Modified files:
- agent/: context_manager.py, gns3_copilot.py, model_factory.py
- gns3_client/: connector_factory.py, context_helpers.py, custom_gns3fy.py,
gns3_project_info.py, gns3_topology_reader.py
- prompts/: __init__.py, lab_automation_assistant_prompt.py,
prompt_loader.py, teaching_assistant_prompt.py
- tools_v2/: __init__.py, config_tools_nornir.py, display_tools_nornir.py,
gns3_create_link.py, gns3_create_node.py, gns3_get_node_temp.py,
gns3_start_node.py, gns3_update_node_name.py,
vpcs_tools_telnetlib3.py
- utils/: __init__.py, command_filter.py, get_gns3_device_port.py,
gns3_drawing_utils.py, llm_config_helper.py, message_converters.py,
parse_tool_content.py, tool_call_stream.py
All files now pass ruff E501 checks.
Co-Authored-By: Yue Guobin <yueguobin@outlook.com>
This commit is contained in:
1 parent
25f2d1b56b
commit
7c3b832bca
32 files changed
+1967
-762
No files matched your search
@@ -55,7 +55,8 @@ def convert_langchain_to_openai(lc_message) -> Dict[str, Any]:
|
||||
Convert LangChain message to OpenAI-compatible format.
|
||||
|
||||
Args:
|
||||
lc_message: LangChain message (HumanMessage, AIMessage, SystemMessage, ToolMessage)
|
||||
lc_message: LangChain message (HumanMessage, AIMessage, SystemMessage,
|
||||
ToolMessage)
|
||||
|
||||
Returns:
|
||||
Dictionary in OpenAI-compatible format
|
||||
@@ -90,7 +91,10 @@ def convert_langchain_to_openai(lc_message) -> Dict[str, Any]:
|
||||
{
|
||||
"id": tc_dict.get("id", str(uuid.uuid4())),
|
||||
"type": "function",
|
||||
"function": {"name": tc_dict.get("name", ""), "arguments": tc_dict.get("args", {})},
|
||||
"function": {
|
||||
"name": tc_dict.get("name", ""),
|
||||
"arguments": tc_dict.get("args", {}),
|
||||
},
|
||||
}
|
||||
)
|
||||
msg["tool_calls"] = tool_calls
|
||||
@@ -149,7 +153,11 @@ def convert_openai_to_langchain(msg: Dict[str, Any]):
|
||||
return ai_msg
|
||||
|
||||
elif role == "tool":
|
||||
return ToolMessage(content=content, name=msg.get("name", ""), tool_call_id=msg.get("tool_call_id", ""))
|
||||
return ToolMessage(
|
||||
content=content,
|
||||
name=msg.get("name", ""),
|
||||
tool_call_id=msg.get("tool_call_id", ""),
|
||||
)
|
||||
|
||||
elif role == "system":
|
||||
return SystemMessage(content=content)
|
||||
@@ -176,7 +184,11 @@ def convert_stream_event_to_openai(event: Dict[str, Any]) -> Dict[str, Any]:
|
||||
content = getattr(chunk, "content", "")
|
||||
|
||||
if content:
|
||||
return {"type": "content", "content": content, "message_id": event.get("metadata", {}).get("msg_id")}
|
||||
return {
|
||||
"type": "content",
|
||||
"content": content,
|
||||
"message_id": event.get("metadata", {}).get("msg_id"),
|
||||
}
|
||||
|
||||
# Check for tool call chunks
|
||||
if hasattr(chunk, "tool_call_chunks") and chunk.tool_call_chunks:
|
||||
@@ -191,12 +203,19 @@ def convert_stream_event_to_openai(event: Dict[str, Any]) -> Dict[str, Any]:
|
||||
"tool_call": {
|
||||
"id": tc_id,
|
||||
"type": "function",
|
||||
"function": {"name": tc_name or "", "arguments": tc_args or ""},
|
||||
"function": {
|
||||
"name": tc_name or "",
|
||||
"arguments": tc_args or "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
elif event_type == "on_tool_start":
|
||||
return {"type": "tool_start", "tool_name": event.get("name", ""), "metadata": event.get("metadata", {})}
|
||||
return {
|
||||
"type": "tool_start",
|
||||
"tool_name": event.get("name", ""),
|
||||
"metadata": event.get("metadata", {}),
|
||||
}
|
||||
|
||||
elif event_type == "on_tool_end":
|
||||
tool_output = event.get("data", {}).get("output", "")
|
||||
|
||||
Reference in new issue
Block a user