openai: only special-format assistant in thoughtful mode

This commit is contained in:
ochafik 2024-03-30 01:55:08 +00:00
parent d9f30f86c8
commit da2067a0d6
2 changed files with 7 additions and 37 deletions

View file

@ -206,7 +206,7 @@ class ChatHandler(ABC):
def render_prompt(self, messages: list[Message]) -> str:
def normalize(m: Message):
if self.style == ToolsPromptStyle.TOOLS_THOUGHTFUL_STEPS:
if self.style == ToolsPromptStyle.TOOLS_THOUGHTFUL_STEPS and m.role == "assistant":
if m.tool_calls:
m = Message(
role=m.role,

View file

@ -66,12 +66,7 @@ Template:
Prompt:
```js
<s>[INST] {
"thought_about_next_step_only": "",
"next_step": {
"result": "Add two numbers for the purpose of this test."
}
} [/INST]{
<s>[INST] Add two numbers for the purpose of this test. [/INST]{
"thought_about_next_step_only": "",
"next_step": {
"tool_calls": [
@ -88,12 +83,7 @@ Prompt:
}
]
}
}</s>[INST] [TOOL(name=None, id=None)]{
"thought_about_next_step_only": "",
"next_step": {
"result": "32222002938"
}
}[/TOOL] [/INST]{
}</s>[INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST]{
"thought_about_next_step_only": "",
"next_step": {
"result": "The sum of 2535 and 32222000403 is 42."
@ -862,12 +852,7 @@ Prompt:
```js
<|im_start|>user
{
"thought_about_next_step_only": "",
"next_step": {
"result": "Add two numbers for the purpose of this test."
}
}<|im_end|>
Add two numbers for the purpose of this test.<|im_end|>
<|im_start|>assistant
{
"thought_about_next_step_only": "",
@ -888,12 +873,7 @@ Prompt:
}
}<|im_end|>
<|im_start|>tool
{
"thought_about_next_step_only": "",
"next_step": {
"result": "32222002938"
}
}<|im_end|>
32222002938<|im_end|>
<|im_start|>assistant
{
"thought_about_next_step_only": "",
@ -1455,12 +1435,7 @@ space ::= " "?
Prompt:
```js
<s>[INST] {
"thought_about_next_step_only": "",
"next_step": {
"result": "Add two numbers for the purpose of this test."
}
} [/INST] {
<s>[INST] Add two numbers for the purpose of this test. [/INST] {
"thought_about_next_step_only": "",
"next_step": {
"tool_calls": [
@ -1477,12 +1452,7 @@ Prompt:
}
]
}
} </s><s>[INST] [TOOL(name=None, id=None)]{
"thought_about_next_step_only": "",
"next_step": {
"result": "32222002938"
}
}[/TOOL] [/INST] {
} </s><s>[INST] [TOOL(name=superSecretTool, id=call_531873)]32222002938[/TOOL] [/INST] {
"thought_about_next_step_only": "",
"next_step": {
"result": "The sum of 2535 and 32222000403 is 42."