Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/examples/healthData/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def _create_request_prompt(self, intent: str) -> str:
now = datetime.now()

prompt = F"""
user: You are a service that translates user requests into JSON objects of type "{self._type_name}" according to the following TypeScript definitions:
user: You are a service that translates user requests into JSON objects of type "{self.type_name}" according to the following TypeScript definitions:
'''
{self._schema_str}
{self.schema_str}
'''

user:
Expand Down
12 changes: 6 additions & 6 deletions python/src/typechat/_internal/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class TypeChatJsonTranslator(Generic[T]):
model: TypeChatLanguageModel
validator: TypeChatValidator[T]
target_type: type[T]
_type_name: str
_schema_str: str
type_name: str
schema_str: str
_max_repair_attempts = 1

def __init__(
Expand Down Expand Up @@ -46,8 +46,8 @@ def __init__(
error_text = "".join(f"\n- {error}" for error in conversion_result.errors)
raise ValueError(f"Could not convert Python type to TypeScript schema: \n{error_text}")

self._type_name = conversion_result.typescript_type_reference
self._schema_str = conversion_result.typescript_schema_str
self.type_name = conversion_result.typescript_type_reference
self.schema_str = conversion_result.typescript_schema_str

async def translate(self, input: str, *, prompt_preamble: str | list[PromptSection] | None = None) -> Result[T]:
"""
Expand Down Expand Up @@ -102,9 +102,9 @@ async def translate(self, input: str, *, prompt_preamble: str | list[PromptSecti

def _create_request_prompt(self, intent: str) -> str:
prompt = f"""
You are a service that translates user requests into JSON objects of type "{self._type_name}" according to the following TypeScript definitions:
You are a service that translates user requests into JSON objects of type "{self.type_name}" according to the following TypeScript definitions:
```
{self._schema_str}
{self.schema_str}
```
The following is a user request:
'''
Expand Down