Python Advanced: Data, Files and JSON
AI data lives in JSON and Lists. Learn to handle nested dictionaries, read context files, and handle the errors that crash production AI pipelines.
Step 1 · concept
Lists and Dictionaries
Chat history is almost always a List of Dictionaries.
messages = [
{"role": "system", "content": "You are helpful."},
{"role": "user", "content": "Hello!"},
]
# Adding a model response
messages.append({"role": "assistant", "content": "Hi there!"})