Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pytest workflow #36

Merged
merged 4 commits into from
Jan 31, 2024
Merged
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
35 changes: 35 additions & 0 deletions .github/workflows/test_cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Python application test

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: '3.10'

- name: Install dependencies
run: |
cd cli
pip install -r requirements.txt

- name: Test with pytest
run: |
cd cli
export PYTHONPATH=$PWD
# For debugging
echo "Current directory: $PWD"
echo "Python path: $PYTHONPATH"
pytest
8 changes: 6 additions & 2 deletions cli/zkappumstad/code_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from openai import OpenAI
from dotenv import load_dotenv, find_dotenv
from zkappumstad.runners import ToolMessage, StateChange

import os
from zkappumstad.tools import (
Tool,
writer_tool,
Expand All @@ -22,7 +22,11 @@

load_dotenv(find_dotenv(".env.local"), override=True)

client = OpenAI()
if os.getenv("OPENAI_API_KEY"):
client = OpenAI()
else:
client = None

tools: dict[str, Tool] = {
tool.name: tool
for tool in [
Expand Down
8 changes: 6 additions & 2 deletions cli/zkappumstad/completion.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from openai import OpenAI
from zkappumstad.prompt import SYSTEM_PROMPT
from dotenv import load_dotenv, find_dotenv

import os

print(find_dotenv(".env.local"))
load_dotenv(find_dotenv(".env.local"))
client = OpenAI()

if os.getenv("OPENAI_API_KEY"):
client = OpenAI()
else:
client = None


def create_completion(history, message):
Expand Down
7 changes: 6 additions & 1 deletion cli/zkappumstad/runner.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from typing import Generator
from json import loads

Expand All @@ -19,7 +20,11 @@

load_dotenv(find_dotenv(".env.local"), override=True)

client = OpenAI()
if os.getenv("OPENAI_API_KEY"):
client = OpenAI()
else:
client = None

tools: dict[str, Tool] = {
tool.name: tool
for tool in [doc_tool, code_tool, project_tool, issue_tool, state_change_tool]
Expand Down
6 changes: 5 additions & 1 deletion cli/zkappumstad/tools/modules_info.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from openai import OpenAI
from dotenv import load_dotenv, find_dotenv
from json import loads
import os

load_dotenv(find_dotenv(".env.local"), override=True)

client = OpenAI()
if os.getenv("OPENAI_API_KEY"):
client = OpenAI()
else:
client = None

SYSTEM_MESSAGE = """
You are a debugger in a o1js project. Your task is to parse any build errors to find the root cause of the error.
Expand Down
7 changes: 5 additions & 2 deletions cli/zkappumstad/tools/prd_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@
from openai import OpenAI
from openai.types.chat import ChatCompletion
from dotenv import load_dotenv, find_dotenv
import os

load_dotenv(find_dotenv(".env.local"))


client = OpenAI()
if os.getenv("OPENAI_API_KEY"):
client = OpenAI()
else:
client = None

function_description = {
"name": "write_prd",
Expand Down
Loading