Skip to content
Discussion options

You must be logged in to vote

hey @BittuChan, You can fix Codex pretty effectively by including a few lines of example code in your prompt as context. Think of it like "few-shot" prompting. You can try something like:

# Modern Python using pathlib and type hints
from pathlib import Path
import json

def read_config(path: Path) -> dict:
    return json.loads(path.read_text())

# Now write a function to read JSON data from a file:

Codex will pick up on the style and continue in that pattern. You can also add a comment at the top like # Python 3.10+ with modern idioms to set expectations.

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@Shiven0504
Comment options

Answer selected by BittuChan
Comment options

You must be logged in to vote
1 reply
@BittuChan
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants