All projects · AI Agents & RAG
Local Python OpenAI Pipeline (moon.py)
A production-grade Python script that queries OpenAI chat completions via a structured 5-stage request pipeline (Configuration > Client Init >…
A production-grade Python script that queries OpenAI chat completions via a structured 5-stage request pipeline (Configuration > Client Init > Prompt Execution > Response Parsing > Error Handling) with zero-key offline mock fallback, resilient exception trapping, and token telemetry.
- 5-stage production request pipeline: configuration > client initialization > prompt execution > response parsing > error handling
- Prioritized credential loading supporting CLI flags, script testing constants, local .env files, and system environment variables
- Zero-key offline mock mode reproducing the exact lunar land price reference wire without external API dependencies
- Robust error containment mapping 401 Unauthorized, 429 Rate Limit, and network timeouts to clean terminal diagnostics without tracebacks
- Automated unit test suite validating configuration precedence, mock payloads, token parsing, and exception mappings
Built with: Python 3.12, OpenAI API v1.x, python-dotenv, Argparse CLI, Chat Completions, Request Pipeline, Error Handling