Skip to content

fix(interactive): skip comment lines when reading requests from a file - #435

Open
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:fix/interactive-skip-comment-lines
Open

Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
microsoft:mainfrom
MohammedAlkindi:fix/interactive-skip-comment-lines

Conversation

@MohammedAlkindi

Copy link
Copy Markdown

processRequests in the TypeScript port dispatches every non-empty line of an input file to the translator. The Python port skips comments first.

python/src/typechat/_internal/interactive.py:

lines = filter(str.rstrip, file)
for line in lines:
    if line.startswith("# "):
        continue

typescript/src/interactive/interactive.ts had only the line.length check, so the header comments in the shipped example are sent as requests. typescript/examples/healthData/src/input.txt opens with # and # Conversations with a Health Data Agent, byte-identical in shape to python/examples/healthData/input.txt, which the Python demo skips.

This aligns the TypeScript branch with the Python one exactly, # prefix and all. Worth noting the parity is literal rather than improved: both ports still pass a bare # line through, since neither tests for it, and I left that alone rather than widening the change.

npm install --ignore-scripts then npx tsc -p src --noEmit both exit 0.

Could not verify: there is no test file for interactive.ts on the TypeScript side, unlike python/tests/test_interactive.py, so there is no existing suite to fail before and pass after.

The Python port filters lines starting with '# ' before dispatching; the TypeScript one did not, so the header comments in the shipped healthData input.txt were sent to the translator as requests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant