Former-commit-id: 6b48308ef9be34d072f3e6bb2444e186a38c2779
This commit is contained in:
hiyouga 2024-07-13 22:07:58 +08:00
parent f616fd61bd
commit 3baf1d1f7e
4 changed files with 10 additions and 10 deletions

View File

@ -16,6 +16,7 @@
# limitations under the License. # limitations under the License.
import asyncio import asyncio
import os
from threading import Thread from threading import Thread
from typing import TYPE_CHECKING, Any, AsyncGenerator, Dict, Generator, List, Optional, Sequence from typing import TYPE_CHECKING, Any, AsyncGenerator, Dict, Generator, List, Optional, Sequence
@ -115,10 +116,8 @@ class ChatModel:
def run_chat() -> None: def run_chat() -> None:
if os.name != "nt":
try: try:
import platform
if platform.system() != "Windows":
import readline # noqa: F401 import readline # noqa: F401
except ImportError: except ImportError:
print("Install `readline` for a better experience.") print("Install `readline` for a better experience.")

View File

@ -25,9 +25,9 @@ DEFAULT_TOOL_PROMPT = (
"You have access to the following tools:\n{tool_text}" "You have access to the following tools:\n{tool_text}"
"Use the following format if using a tool:\n" "Use the following format if using a tool:\n"
"```\n" "```\n"
"Action: tool name (one of [{tool_names}]).\n" "Action: tool name (one of [{tool_names}])\n"
"Action Input: the input to the tool, in a JSON format representing the kwargs " "Action Input: the input to the tool, in a JSON format representing the kwargs "
"""(e.g. ```{{"input": "hello world", "num_beams": 5}}```).\n""" """(e.g. ```{{"input": "hello world", "num_beams": 5}}```)\n"""
"```\n" "```\n"
) )

View File

@ -117,6 +117,7 @@ def gen_cmd(args: Dict[str, Any]) -> str:
cmd_text = "`\n".join(cmd_lines) cmd_text = "`\n".join(cmd_lines)
else: else:
cmd_text = "\\\n".join(cmd_lines) cmd_text = "\\\n".join(cmd_lines)
cmd_text = "```bash\n{}\n```".format(cmd_text) cmd_text = "```bash\n{}\n```".format(cmd_text)
return cmd_text return cmd_text

View File

@ -69,9 +69,9 @@ def test_default_tool_formatter():
" - bar (number): bar_desc\n\n" " - bar (number): bar_desc\n\n"
"Use the following format if using a tool:\n" "Use the following format if using a tool:\n"
"```\n" "```\n"
"Action: tool name (one of [test_tool]).\n" "Action: tool name (one of [test_tool])\n"
"Action Input: the input to the tool, in a JSON format representing the kwargs " "Action Input: the input to the tool, in a JSON format representing the kwargs "
"""(e.g. ```{"input": "hello world", "num_beams": 5}```).\n""" """(e.g. ```{"input": "hello world", "num_beams": 5}```)\n"""
"```\n" "```\n"
] ]