Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New (Python) example: simple drawings (rectangle, ellipse, arrow) #238

Draft
wants to merge 29 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bb9e32f
Install python-dotenv and tabulate
gvanrossum Apr 17, 2024
6737581
Small working demo that can draw boxes on a canvas
gvanrossum Apr 17, 2024
de03aa9
Add chat history to drawing demo
gvanrossum Apr 17, 2024
2edaedd
[WIP] Hack on translation a bit
gvanrossum Apr 17, 2024
09ea859
New API for chat history
gvanrossum Apr 18, 2024
c52aa53
Improved the schema with ChatGPT's help. Added Arrow and Ellipse.
gvanrossum Apr 19, 2024
5d07a2a
rendering program using Tkinter
gvanrossum Apr 19, 2024
f46a836
Add a simple rendering function (most of it written by ChatGPT)
gvanrossum Apr 19, 2024
131ad4f
Added dashed and dotted arrows (some help from ChatGPT)
gvanrossum Apr 19, 2024
3f44129
Merge commit '66fd7bb' into drawing
gvanrossum Apr 20, 2024
b90faa7
Rip oput history, for now
gvanrossum Apr 22, 2024
02e28e4
Make pyright happy
gvanrossum Apr 22, 2024
3e1f3e6
Merge branch 'main' into drawing
gvanrossum Apr 22, 2024
e9ac5cf
Keep pydantic also happy
gvanrossum Apr 22, 2024
9e14f42
Add (flawed) history based on prompt_preamble
gvanrossum Apr 22, 2024
75c2efe
Prune history
gvanrossum Apr 22, 2024
970d50b
Add temporary logging
gvanrossum Apr 22, 2024
7560273
Alternate prompting scheme from #241
gvanrossum Apr 22, 2024
439f521
Revert changes to translator.py
gvanrossum May 2, 2024
b0fdd8d
Merge branch 'main' into drawing
gvanrossum May 2, 2024
d385e40
Use Anders' suggestion for history
gvanrossum May 2, 2024
42ce16a
Switch schema to dataclasses
gvanrossum May 2, 2024
c6da914
Black formatting
gvanrossum May 2, 2024
390558e
Remove unused imports
gvanrossum May 2, 2024
e42b2dd
Clarify Failure output
gvanrossum May 2, 2024
11edfb7
Revert verbose logging
gvanrossum May 2, 2024
3f099dc
Reuse drawing window
gvanrossum May 2, 2024
5c6e15f
Don't crash if we cannot import readline (e.g. on Windows)
gvanrossum May 8, 2024
0894ef6
Add crude progress messages
gvanrossum May 8, 2024
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
Prev Previous commit
Next Next commit
Prune history
gvanrossum committed Apr 22, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 75c2efe03075a16b1010bcc5ccca16d2daced94c
5 changes: 5 additions & 0 deletions python/examples/drawing/demo.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,11 @@ async def main(file_path: str | None):
history: list[PromptSection] = []

async def request_handler(request: str):
if len(history) > 10:
# Prune history
old = history[:-10]
old = [item for item in old if item["role"] == "user"]
history[:-10] = old
result: Success[drawing.Drawing] | Failure = await translator.translate(request, prompt_preamble=history)
if isinstance(result, Failure):
print(result.message)