Skip to content

Commit

Permalink
Ensure the repair prompt is actually appended to our messages and upd…
Browse files Browse the repository at this point in the history
…ate snapshots.
  • Loading branch information
DanielRosenwasser committed Apr 20, 2024
1 parent af2cf1b commit 48a4ab3
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 53 deletions.
4 changes: 2 additions & 2 deletions python/examples/healthData/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def __init__(
self._additional_agent_instructions = additional_agent_instructions

@override
async def translate(self, request: str, *, prompt_preamble: str | list[PromptSection] | None = None) -> Result[T]:
result = await super().translate(request=request, prompt_preamble=prompt_preamble)
async def translate(self, input: str, *, prompt_preamble: str | list[PromptSection] | None = None) -> Result[T]:

Check failure on line 30 in python/examples/healthData/translator.py

View workflow job for this annotation

GitHub Actions / pyright (ubuntu-latest, 3.11)

Method "translate" overrides class "TypeChatJsonTranslator" in an incompatible manner   Parameter 2 name mismatch: base parameter is named "request", override parameter is named "input" (reportIncompatibleMethodOverride)
result = await super().translate(input=input, prompt_preamble=prompt_preamble)

Check failure on line 31 in python/examples/healthData/translator.py

View workflow job for this annotation

GitHub Actions / pyright (ubuntu-latest, 3.11)

Type of "result" is unknown (reportUnknownVariableType)

Check failure on line 31 in python/examples/healthData/translator.py

View workflow job for this annotation

GitHub Actions / pyright (ubuntu-latest, 3.11)

Argument missing for parameter "request" (reportCallIssue)

Check failure on line 31 in python/examples/healthData/translator.py

View workflow job for this annotation

GitHub Actions / pyright (ubuntu-latest, 3.11)

No parameter named "input" (reportCallIssue)
if not isinstance(result, Failure):
self._chat_history.append(ChatMessage(source="assistant", body=result.value))

Check failure on line 33 in python/examples/healthData/translator.py

View workflow job for this annotation

GitHub Actions / pyright (ubuntu-latest, 3.11)

Type of "value" is unknown (reportUnknownMemberType)
return result

Check failure on line 34 in python/examples/healthData/translator.py

View workflow job for this annotation

GitHub Actions / pyright (ubuntu-latest, 3.11)

Return type, "Unknown | Failure", is partially unknown (reportUnknownVariableType)
Expand Down
155 changes: 104 additions & 51 deletions python/tests/__snapshots__/test_translator.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,33 @@
list([
dict({
'kind': 'CLIENT REQUEST',
'payload': '''

You are a service that translates user requests into JSON objects of type "ExampleABC" according to the following TypeScript definitions:
```
interface ExampleABC {
a: string;
b: boolean;
c: number;
}

```
The following is a user request:
'''
Get me stuff.
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:
'payload': list([
dict({
'content': 'Get me stuff.',
'role': 'user',
}),
dict({
'content': '''

You are a service that translates user requests into JSON objects of type "ExampleABC" according to the following TypeScript definitions:
```
interface ExampleABC {
a: string;
b: boolean;
c: number;
}

```
The following is a user request:
'''
Get me stuff.
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:

''',
''',
'role': 'user',
}),
]),
}),
dict({
'kind': 'MODEL RESPONSE',
Expand All @@ -32,49 +41,93 @@
list([
dict({
'kind': 'CLIENT REQUEST',
'payload': '''

You are a service that translates user requests into JSON objects of type "ExampleABC" according to the following TypeScript definitions:
```
interface ExampleABC {
a: string;
b: boolean;
c: number;
}

```
The following is a user request:
'''
Get me stuff.
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:
'payload': list([
dict({
'content': 'Get me stuff.',
'role': 'user',
}),
dict({
'content': '''

You are a service that translates user requests into JSON objects of type "ExampleABC" according to the following TypeScript definitions:
```
interface ExampleABC {
a: string;
b: boolean;
c: number;
}

```
The following is a user request:
'''
Get me stuff.
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:

''',
''',
'role': 'user',
}),
dict({
'content': '''

The above JSON object is invalid for the following reason:
'''
Validation path `c` failed for value `{"a": "hello", "b": true}` because:
Field required
'''
The following is a revised JSON object:

''',
'role': 'user',
}),
]),
}),
dict({
'kind': 'MODEL RESPONSE',
'payload': '{ "a": "hello", "b": true }',
}),
dict({
'kind': 'CLIENT REQUEST',
'payload': '''

You are a service that translates user requests into JSON objects of type "ExampleABC" according to the following TypeScript definitions:
```
interface ExampleABC {
a: string;
b: boolean;
c: number;
}

```
The following is a user request:
'''
Get me stuff.
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:
'payload': list([
dict({
'content': 'Get me stuff.',
'role': 'user',
}),
dict({
'content': '''

You are a service that translates user requests into JSON objects of type "ExampleABC" according to the following TypeScript definitions:
```
interface ExampleABC {
a: string;
b: boolean;
c: number;
}

```
The following is a user request:
'''
Get me stuff.
'''
The following is the user request translated into a JSON object with 2 spaces of indentation and no properties with the value undefined:

''',
'role': 'user',
}),
dict({
'content': '''

The above JSON object is invalid for the following reason:
'''
Validation path `c` failed for value `{"a": "hello", "b": true}` because:
Field required
'''
The following is a revised JSON object:

''',
''',
'role': 'user',
}),
]),
}),
dict({
'kind': 'MODEL RESPONSE',
Expand Down

0 comments on commit 48a4ab3

Please sign in to comment.