A small Python CLI that talks to OpenAI to generate concise motivational guidance and a short preparation checklist targeted at students preparing for FAANG/MAANG-style interviews.
app.py– CLI entry point. Invokes the agent and writes output togpt_output.text.ai_motivational_agent.py– The agent class that builds the prompt and formats the response.openai_client.py– Lightweight wrapper around the OpenAI Python client. ReadsOPENAI_API_KEYfrom environment.TestGPTAPI.py– Example/test file (contains a hard-coded API key — see Security notes).gpt_output.text– (Generated) output file created byapp.pywhen a response is written.
- Python 3.8 or newer
openaiPython package
You can install the package directly:
python -m pip install --upgrade pip
python -m pip install openai(Optionally create a requirements.txt with openai if you prefer.)
- Create and activate a virtual environment (recommended):
python -m venv .venv
.\.venv\Scripts\Activate.ps1- Install dependencies:
pip install openai- Set your OpenAI API key in the environment (do NOT hard-code it):
$env:OPENAI_API_KEY = "your_api_key_here"
# To persist the variable for the current user, use setx (re-open shell to take effect):
# setx OPENAI_API_KEY "your_api_key_here"Run the CLI. You may optionally provide a student name and a focus area.
python app.py # uses defaults: name -> "student", focus -> "DSA and System design"
python app.py Alice "system design" # pass name and focus areaOn success, the script writes an output file named gpt_output.text and prints the advice to the console.
openai_client.pyreadsOPENAI_API_KEYfrom the environment. Do not put keys directly into source files.- I noticed
TestGPTAPI.pycontains an embedded API key. That is a secret and must be removed immediately. If this repository has been committed to a public or shared VCS, consider rotating the API key and purging the secret from your git history.
Suggested quick actions:
- Delete or edit
TestGPTAPI.pyto remove the API key. - Rotate the exposed API key in your OpenAI dashboard.
- If the key was committed, use tools such as
git filter-repoorgit filter-branchto remove the secret from history (follow your org's policy).
app.py: CLI wrapper that validates the environment, creates the chat client and agent, invokes the agent, writes the result togpt_output.text, and prints the result.ai_motivational_agent.py: Prompts the model with a structured prompt to produce a short motivation and a small checklist.openai_client.py: Thin wrapper usingopenai.OpenAI()to callchat.completions.create(...)and return text. It raises RuntimeError on failures.
- If you see errors about authentication, confirm
OPENAI_API_KEYis set in the shell you run the script from. - If the model fails or returns empty, check network access and your OpenAI account quota/model access.
If you'd like, I can:
- Add a
requirements.txtand a small.gitignore(to ignore.venvand output files). - Remove or redact the API key from
TestGPTAPI.pyand create a safe example demonstrating environment variable usage instead.
Created automatically to document how to run and secure this project.