harrison/add-usage-readmes
parent
3ad628c022
commit
c0c3817cb2
@ -0,0 +1,21 @@
|
||||
name: file-check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
python-version:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install langchain
|
||||
run: |
|
||||
pipx install -U langchain
|
||||
- name: Analysing the files with our Make command
|
||||
run: |
|
||||
make file-check
|
@ -0,0 +1,4 @@
|
||||
.PHONY: file-check
|
||||
|
||||
file-check:
|
||||
python ci_scripts/file-check.py
|
@ -0,0 +1,33 @@
|
||||
from pathlib import Path
|
||||
|
||||
from langchain.prompts import load_prompt
|
||||
|
||||
BASE_FOLDER = Path("prompts")
|
||||
folders = BASE_FOLDER.glob("**")
|
||||
|
||||
|
||||
def check_files(files):
|
||||
if len(files) != 2:
|
||||
raise ValueError(f"Each directory should have two files, got {len(files)}")
|
||||
file_names = [f.name for f in files]
|
||||
if "README.md" not in file_names:
|
||||
raise ValueError(f"Expected to find a README.md file, but found {files}")
|
||||
other_file = [file for file in files if file.name != "README.md"][0]
|
||||
if other_file.suffix in (".json", ".yaml"):
|
||||
load_prompt(other_file)
|
||||
# TODO: testing for python files
|
||||
|
||||
|
||||
def check_all_folders():
|
||||
for folder in folders:
|
||||
folder_path = Path(folder)
|
||||
files = [x for x in folder_path.iterdir() if x.is_file()]
|
||||
if len(files) > 0:
|
||||
try:
|
||||
check_files(files)
|
||||
except Exception as e:
|
||||
raise ValueError(f"Found error with {folder}: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
check_all_folders()
|
Loading…
Reference in New Issue