Enhance llm_debug_script.py to allow dynamic username input
This commit is contained in:
parent
c2761927ad
commit
f191ab3315
@ -436,6 +436,14 @@ Wolf Chat 是一個基於 MCP (Modular Capability Provider) 框架的聊天機
|
|||||||
- 實現進程追蹤和按鈕狀態管理,確保在有腳本運行時禁用運行按鈕,啟用停止按鈕。
|
- 實現進程追蹤和按鈕狀態管理,確保在有腳本運行時禁用運行按鈕,啟用停止按鈕。
|
||||||
- **效果**:提高了 `Setup.py` 的易用性,方便使用者在調整設定後直接啟動腳本進行測試,並提供了便捷的終止方式。
|
- **效果**:提高了 `Setup.py` 的易用性,方便使用者在調整設定後直接啟動腳本進行測試,並提供了便捷的終止方式。
|
||||||
|
|
||||||
|
### llm_debug_script.py 功能增強
|
||||||
|
|
||||||
|
- **目的**:讓用戶在啟動時能夠輸入自己的名字。
|
||||||
|
- **修改內容**:
|
||||||
|
- 新增了一個 `get_username()` 函數來提示用戶輸入名字
|
||||||
|
- 在 `debug_loop()` 函數中,刪除了固定的 `user_name = "Debugger"` 行,並替換為從 `get_username()` 函數獲取名字的調用
|
||||||
|
- **效果**:修改後,腳本啟動時會提示用戶輸入自己的名字。如果用戶直接按 Enter 而不輸入任何名字,它將使用預設的 `Debugger` 作為用戶名。輸入完名字後,腳本會繼續執行原來的功能。
|
||||||
|
|
||||||
## 開發建議
|
## 開發建議
|
||||||
|
|
||||||
### 優化方向
|
### 優化方向
|
||||||
|
|||||||
@ -146,6 +146,16 @@ async def shutdown():
|
|||||||
all_discovered_mcp_tools.clear()
|
all_discovered_mcp_tools.clear()
|
||||||
print("Cleanup completed.")
|
print("Cleanup completed.")
|
||||||
|
|
||||||
|
# --- Get Username Function ---
|
||||||
|
async def get_username():
|
||||||
|
"""Prompt the user for their name and return it."""
|
||||||
|
print("\nPlease enter your name (or press Enter to use 'Debugger'): ", end="")
|
||||||
|
user_input = await asyncio.get_event_loop().run_in_executor(None, sys.stdin.readline)
|
||||||
|
user_name = user_input.strip()
|
||||||
|
if not user_name:
|
||||||
|
user_name = "Debugger" # Default name if nothing is entered
|
||||||
|
return user_name
|
||||||
|
|
||||||
# --- Main Debug Loop ---
|
# --- Main Debug Loop ---
|
||||||
async def debug_loop():
|
async def debug_loop():
|
||||||
"""Main loop for interactive LLM debugging."""
|
"""Main loop for interactive LLM debugging."""
|
||||||
@ -162,13 +172,15 @@ async def debug_loop():
|
|||||||
if confirm.strip().lower() != 'y':
|
if confirm.strip().lower() != 'y':
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 3. Get username
|
||||||
|
user_name = await get_username()
|
||||||
|
print(f"Debug session started as: {user_name}")
|
||||||
|
|
||||||
print("\n--- LLM Debug Interface ---")
|
print("\n--- LLM Debug Interface ---")
|
||||||
print("Enter your message to the LLM.")
|
print("Enter your message to the LLM.")
|
||||||
print("Type 'quit' or 'exit' to stop.")
|
print("Type 'quit' or 'exit' to stop.")
|
||||||
print("-----------------------------")
|
print("-----------------------------")
|
||||||
|
|
||||||
user_name = "Debugger" # Fixed user name for this script
|
|
||||||
|
|
||||||
while not shutdown_requested:
|
while not shutdown_requested:
|
||||||
try:
|
try:
|
||||||
# Get user input asynchronously
|
# Get user input asynchronously
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user