Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.env
env
venv
__pycache__
.vscode
.idea
Expand Down
11 changes: 6 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from constants import DEFAULT_DIR, DEFAULT_MODEL, DEFAULT_MAX_TOKENS

stub = modal.Stub("smol-developer-v1") # yes we are recommending using Modal by default, as it helps with deployment. see readme for why.
openai_image = modal.Image.debian_slim().pip_install("openai", "tiktoken")
openai_image = modal.Image.debian_slim().pip_install("openai", "tiktoken", "promptlayer")

@stub.function(
image=openai_image,
Expand All @@ -20,17 +20,18 @@
)
def generate_response(model, system_prompt, user_prompt, *args):
# IMPORTANT: Keep import statements here due to Modal container restrictions https://modal.com/docs/guide/custom-container#additional-python-packages
import openai
import tiktoken
import promptlayer
openai = promptlayer.openai

def reportTokens(prompt):
encoding = tiktoken.encoding_for_model(model)
# print number of tokens in light gray, with first 50 characters of prompt in green. if truncated, show that it is truncated
print("\033[37m" + str(len(encoding.encode(prompt))) + " tokens\033[0m" + " in prompt: " + "\033[92m" + prompt[:50] + "\033[0m" + ("..." if len(prompt) > 50 else ""))


# Set up your OpenAI API credentials
openai.api_key = os.environ["OPENAI_API_KEY"]
# # Set up your OpenAI API credentials
# openai.api_key = os.environ["OPENAI_API_KEY"]

messages = []
messages.append({"role": "system", "content": system_prompt})
Expand Down Expand Up @@ -144,7 +145,7 @@ def main(prompt, directory=DEFAULT_DIR, model=DEFAULT_MODEL, file=None):

# understand shared dependencies
shared_dependencies = generate_response.call(model,
"""You are an AI developer who is trying to write a program that will generate code for the user based on their intent.
f"""You are an AI developer who is trying to write a program that will generate code for the user based on their intent.

In response to the user's prompt:

Expand Down
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# note to reader: these requirements are ONLY if you are running the _no_modal variants of the files
# if you are running the default variants (main.py, debugger.py, etc), you do not need to install these requirements
modal
openai
tiktoken
promptlayer
python-dotenv
-e ../mergedbots