New (Python) example: simple drawings (rectangle, ellipse, arrow)#238
Conversation
The idea is that you can write a small amount of JavaScript that reads the JSON and renders in an HTML5 canvas, or some Python that renders it in Tkinter, or anything else that strikes your fancy. I would like to use this to draw diagrams representing the stack and memory layout for an interpreter, to be used in internal docs.
|
There's some stuff here that makes intuitive sense, but I'll need to check in with others (CC @ahejlsberg) I would think that the best format for incorporating chat history would be something like
That gives background for the current convo, plus reinforces the current task at hand. This PR is pretty close to that. |
|
I wonder how to proceed. Clearly this PR two things (adding history and adding a new example) and that's not great. Your fixes to the translator (#240) broke my PR and I would rather not try to merge it back. I propose to add my example without chat history and start a separate discussion on chat history -- okay? |
(Just append the inputs, separated by newlines.)
There was a problem hiding this comment.
Pull request overview
Adds a new Python “drawing” example that translates natural-language requests into a typed drawing schema and renders the result with Tkinter, plus a couple of small usability/dependency updates elsewhere.
Changes:
- Add
python/examples/drawingexample (schema + Tkinter renderer + interactive demo + sample input). - Make
readlineusage in the interactive request loop optional (avoid crashing where it’s unavailable). - Update the CoffeeShop notebook’s bootstrap installs (add
python-dotenvandtabulate).
Show a summary per file
| File | Description |
|---|---|
| python/src/typechat/_internal/interactive.py | Makes readline import optional for interactive mode. |
| python/notebooks/coffeeShop.ipynb | Adds notebook runtime deps (python-dotenv, tabulate). |
| python/examples/drawing/schema.py | Introduces a drawing schema (Box/Ellipse/Arrow/etc.) with style metadata. |
| python/examples/drawing/render.py | Adds Tkinter rendering for the drawing schema. |
| python/examples/drawing/demo.py | Adds an interactive demo that maintains simple request history and re-renders. |
| python/examples/drawing/input.txt | Provides sample prompts for the drawing demo. |
| python/examples/drawing/init.py | Initializes the new example package. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 5
…d interactive input helper Restrict Style.line_style to Literal["solid", "dashed", "dotted"], align the UnknownText discriminant to Literal["Unknown"], fix the Arrow docstring, harden the dash-pattern lookup with a safe fallback to solid, and mark the optional readline import as intentionally unused (noqa: F401).
|
@copilot resolve the merge conflicts in this pull request |
For me, this works best with openai model gpt-3.5-turbo; gpt-4 seems worse (?!).
Here's a sample session (no longer valid without history support)