prompts in python are not saved it the database
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 12.5k
- Forks
- 998
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 10
Description
Hello!
So I was using llm to make requests using the python api, and it seems that the prompts used in the python api are not saved into the database.
For me it was the expected behavior, because the docs says "llm defaults to logging all prompts and responses to a SQLite database.", and nothing on the python API page nor the Logging to SQLite.
Is this intended and not documented, a bug, or am I missing something?
small reproducible test:
test.py:
import llm
model = llm.get_model("gpt-4o-mini")
response = model.prompt("Five surprising names for a pet pelican")
print(response.text())
uv init && uv add llmuv run llm logs -n 1-> output your last messageuv run test.py-> print 5 namesuv run llm logs -n 1-> should print "Five surprising names for a pet pelican" and the answer, print the same as 2.
Otherwise, thank you very much for your amazing work, it really helps me a lot!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproducible test.py example and run the two uv run llm logs -n 1 commands around model.prompt(...) to confirm the difference between CLI and Python API logging. Trace the Python API logging path and SQLite persistence behavior. Done means the prompt and response from the Python API appear in llm logs, or the documentation clearly explains that they are intentionally excluded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlite
- Domain
- api, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100