From the root of this repo:
Create a virtual env and activate.
python3 -m venv .venv
How you activate the environment depends on your operating system and shell. Typically, it involves sourcing an
activate
script located in the virtual environment'sbin
(Unix-based) orScripts
(Windows) directory.
For Unix-based systems:
. ./.venv/bin/activate
For Windows Command Prompt:
.\.venv\Scripts\activate
Install ai_coder into your pip environment with:
pip install -e .
This installs the ai_coder package in editable mode. All imports of ai_coder will run the ai_coder source at ./ai_coder
directly.
First, you need to find the absolute path to ai_coder's directory. This is the directory that contains the setup.py
file. You can navigate to this directory in your terminal and use a command to get the path:
- On Unix-based systems (Linux, macOS), you can use
pwd
. - On Windows, you can use
cd
without arguments orecho %cd%
in Command Prompt (orecho $PWD
in PowerShell).
Before you install ai_coder as a dependency in Project B, make sure Project B's virtual environment is activated.
With Project B's virtual environment activated, use pip
to install ai_coder in editable mode using the path you obtained in Step 1. Replace /path/to/projectA
with the actual path to ai_coder:
pip install -e /path/to/ai_coder
This command will install ai_coder into Project B's virtual environment in editable mode. Any changes made to ai_coder's code will be reflected in Project B without needing to reinstall ai_coder.
It currently executes the prompt with OpenAI, so you'll need to use your own OpenAI API Key
export OPENAI_API_KEY=sk-abcdefghijklmnopqrstuvwxyz
from ai_coder.ai_decorators import ai_code
@ai_code
def get_top_hacker_news():
return """Implement a function that can fetch the top hacker news, which mention certain keywords, e.g. 'gpt', 'llm', 'workflow', 'serverless'.
You can use the url \"https://hacker-news.firebaseio.com/v0/topstories.json\" to fetch the top hacker news.
Please only return the story title and the url.
The input is the keywords and the output is a list of the news."""
ai_coder gen prompts/src/my_code.py