Updated README and projects with details of APIs and costs, and common setup troubleshooting
This commit is contained in:
@@ -7,7 +7,11 @@
|
||||
"source": [
|
||||
"# Code Generator\n",
|
||||
"\n",
|
||||
"The requirement: use a Frontier model to generate high performance C++ code from Python code"
|
||||
"The requirement: use a Frontier model to generate high performance C++ code from Python code\n",
|
||||
"\n",
|
||||
"# Important Note\n",
|
||||
"\n",
|
||||
"In the exercise I use GPT-4o and Claude-3.5-Sonnet, which are the slightly higher priced versions. The costs are still low, but if you'd prefer to keep costs ultra low, please make the suggested switches to the models (3 cells down from here)."
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -53,11 +57,16 @@
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# initialize\n",
|
||||
"# NOTE - option to use ultra-low cost models by uncommenting last 2 lines\n",
|
||||
"\n",
|
||||
"openai = OpenAI()\n",
|
||||
"claude = anthropic.Anthropic()\n",
|
||||
"OPENAI_MODEL = \"gpt-4o\"\n",
|
||||
"CLAUDE_MODEL = \"claude-3-5-sonnet-20240620\""
|
||||
"CLAUDE_MODEL = \"claude-3-5-sonnet-20240620\"\n",
|
||||
"\n",
|
||||
"# Want to keep costs ultra-low? Uncomment these lines:\n",
|
||||
"# OPENAI_MODEL = \"gpt-4o-mini\"\n",
|
||||
"# CLAUDE_MODEL = \"claude-3-haiku-20240307\""
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -213,6 +222,21 @@
|
||||
"exec(pi)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bf8f8018-f64d-425c-a0e1-d7862aa9592d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Compiling C++ and executing\n",
|
||||
"\n",
|
||||
"This next cell contains the command to compile a C++ file on my M1 Mac. \n",
|
||||
"It compiles the file `optimized.cpp` into an executable called `optimized` \n",
|
||||
"Then it runs the program called `optimized`\n",
|
||||
"\n",
|
||||
"You can google (or ask ChatGPT!) for how to do this on your platform, then replace the lines below.\n",
|
||||
"If you're not comfortable with this step, you can skip it for sure - I'll show you exactly how it performs on my Mac."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
@@ -220,6 +244,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Compile C++ and run the executable\n",
|
||||
"\n",
|
||||
"!clang++ -O3 -std=c++17 -march=armv8.3-a -o optimized optimized.cpp\n",
|
||||
"!./optimized"
|
||||
]
|
||||
@@ -241,6 +267,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Repeat for Claude - again, use the right approach for your platform\n",
|
||||
"\n",
|
||||
"!clang++ -O3 -std=c++17 -march=armv8.3-a -o optimized optimized.cpp\n",
|
||||
"!./optimized"
|
||||
]
|
||||
@@ -323,6 +351,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Replace this with the right C++ compile + execute command for your platform\n",
|
||||
"\n",
|
||||
"!clang++ -O3 -std=c++17 -march=armv8.3-a -o optimized optimized.cpp\n",
|
||||
"!./optimized"
|
||||
]
|
||||
@@ -344,6 +374,8 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Replace this with the right C++ compile + execute command for your platform\n",
|
||||
"\n",
|
||||
"!clang++ -O3 -std=c++17 -march=armv8.3-a -o optimized optimized.cpp\n",
|
||||
"!./optimized"
|
||||
]
|
||||
@@ -447,6 +479,12 @@
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# You'll need to change the code in the try block to compile the C++ code for your platform\n",
|
||||
"# I pasted this into Claude's chat UI with a request for it to give me a version for an Intel PC,\n",
|
||||
"# and it responded with something that looks perfect - you can try a similar approach for your platform.\n",
|
||||
"\n",
|
||||
"# M1 Mac version to compile and execute optimized C++ code:\n",
|
||||
"\n",
|
||||
"def execute_cpp(code):\n",
|
||||
" write_output(code)\n",
|
||||
" try:\n",
|
||||
|
||||
Reference in New Issue
Block a user