Skip to content

Commit

Permalink
Alternate prompting scheme from #241
Browse files Browse the repository at this point in the history
  • Loading branch information
gvanrossum committed Apr 22, 2024
1 parent 970d50b commit 7560273
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions python/src/typechat/_internal/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ async def translate(self, input: str, *, prompt_preamble: str | list[PromptSecti

messages: list[PromptSection] = []

messages.append({"role": "user", "content": input})
messages.append({"role": "system", "content": self._create_request_prompt(input)})

if prompt_preamble:
if isinstance(prompt_preamble, str):
prompt_preamble = [{"role": "user", "content": prompt_preamble}]
else:
messages.extend(prompt_preamble)
messages.extend(prompt_preamble)

messages.append({"role": "user", "content": self._create_request_prompt(input)})
messages.append({"role": "user", "content": input})

num_repairs_attempted = 0
while True:
Expand Down Expand Up @@ -103,11 +103,7 @@ def _create_request_prompt(self, intent: str) -> str:
```
{self._schema_str}
```
The following is a user request:
'''
{intent}
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:
You translate each user request into a JSON object with 2 spaces of indentation and no properties with the value undefined.
"""
return prompt

Expand Down

0 comments on commit 7560273

Please sign in to comment.