This commit is contained in:
hiyouga 2024-07-13 22:07:58 +08:00
parent 32699a82a6
commit 6b48308ef9
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,13 +116,11 @@ class ChatModel:
def run_chat() -> None: def run_chat() -> None:
try: if os.name != "nt":
import platform try:
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.")
chat_model = ChatModel() chat_model = ChatModel()
messages = [] messages = []

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"
] ]