Skip to content

Week4 exercise bootcamp feb2026 ibrahim sheriff#1

Open
Sheriff10 wants to merge 2 commits into
mainfrom
week4_exercise_bootcamp_feb2026_IbrahimSheriff
Open

Week4 exercise bootcamp feb2026 ibrahim sheriff#1
Sheriff10 wants to merge 2 commits into
mainfrom
week4_exercise_bootcamp_feb2026_IbrahimSheriff

Conversation

@Sheriff10
Copy link
Copy Markdown
Owner

Week 4: Code gen and unit-test AI

What it is

A Gradio app (launched from the notebook) that uses a frontier LLM via OpenRouter to:

  • Convert Python → TypeScript — Generate idiomatic, typed TypeScript from Python with equivalent behavior.
  • Run code — Run the Python or TypeScript in the app and compare outputs.
  • Generate unit tests — Choose Python (pytest) or TypeScript (Jest) and generate tests for the code in the corresponding box.

Notebook: week4/python_to_typescript.ipynb.

Setup

  1. API key: Put your OpenRouter API key in a .env file in the repo root:

    OPENROUTER_API_KEY=sk-or-v1-...
    

    Get a key at openrouter.ai.

  2. Dependencies: From the repo root run:

    uv sync

    Or install: python-dotenv, openai, gradio.

How to run

  1. Open and run week4/python_to_typescript.ipynb.
  2. Run all cells to load the client and start the Gradio app.
  3. Use the local URL (e.g. http://127.0.0.1:7860) in your browser.
  4. Convert: Paste Python, pick a model, click Convert to get TypeScript.
  5. Run: Use Run Python and Run TypeScript to see outputs.
  6. Unit tests: Choose Python or TypeScript in the dropdown and click Generate unit tests to get pytest or Jest tests.

Optional: Run TypeScript in the app

The Run TypeScript button uses npx tsx (or npx ts-node). You need:

  • Node.js installed.
  • tsx or ts-node, e.g.:
    • npx tsx (recommended, no global install),
    • or npm i -g ts-node.

If neither is available, the app will show an install message.

Comment on lines +61 to +69
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenRouter API Key exists and begins sk-or-v1\n"
]
}
],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"OpenRouter API Key exists and begins sk-or-v1\n"
]
}
],
"outputs": [],

Comment on lines +429 to +458
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7864\n",
"* To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7864/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"* Running on local URL: http://127.0.0.1:7864\n",
"* To create a public link, set `share=True` in `launch()`.\n"
]
},
{
"data": {
"text/html": [
"<div><iframe src=\"http://127.0.0.1:7864/\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
],
"text/plain": [
"<IPython.core.display.HTML object>"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": []
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],

@hopeogbons
Copy link
Copy Markdown
Collaborator

Hey @Sheriff10 kindly resolve the suggestions above.

#LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants