Skip to content

Commit

Permalink
Remove legacy scripts and update composer configuration
Browse files Browse the repository at this point in the history
Removed deprecated batch and shell scripts, and redundant prompt documentation. Added instructor binary to composer.json and restructured namespace autoloading for better organization.
  • Loading branch information
ddebowczyk committed Nov 1, 2024
1 parent 742a973 commit 3f74074
Show file tree
Hide file tree
Showing 69 changed files with 4,841 additions and 3,875 deletions.
2 changes: 1 addition & 1 deletion .env-dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# INSTRUCTOR SECRETS
#########################################################

INSTRUCTOR_CONFIG_PATH='/../../config/'
INSTRUCTOR_CONFIG_PATH='../../config/'

#########################################################
# LLMS
Expand Down
52 changes: 52 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Exclude unnecessary files from Composer and Git exports
/docs/ export-ignore
#/evals/ export-ignore # include this one with distribution
#/examples/ export-ignore # include this one with distribution
/notes/ export-ignore
/tests/ export-ignore
/.github/ export-ignore
/.gitignore export-ignore
/.gitattributes export-ignore
/phpunit.xml export-ignore
/phpstan.neon export-ignore
/phpstan.neon.dist export-ignore
/psalm.xml export-ignore
/composer.lock export-ignore
*.md export-ignore
*.mdx export-ignore

# Line ending normalization
# Ensure PHP, JS, and text files have consistent line endings
*.php text eol=lf
*.js text eol=lf
*.css text eol=lf
*.html text eol=lf
*.txt text eol=lf
*.md text eol=lf
*.mdx text eol=lf
*.xml text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.sh text eol=lf
*.bat text eol=lf

# Treat binary files as binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.pdf binary
*.svg binary

# Linguist overrides (optional for GitHub)
*.md linguist-documentation
*.json linguist-vendored
/vendor/ linguist-vendored

# Ignore logs and temp files in exports (optional)
*.log export-ignore
/tmp/ export-ignore
/cache/ export-ignore
*.bak export-ignore
*.swp export-ignore
56 changes: 45 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,48 @@
.cache/
.idea/
# Composer dependency and autoload files
composer.lock

# Dependencies
/vendor/

# env files
.env
.env.local
.env.*.local

# Logs and debug files
*.log
*.cache

# PHP server and error logs
error_log
.php_error.log
php_errors.log

# Node modules and build artifacts (if using Node or frontend tooling)
node_modules/
dist/
build/

# Python venvs
.venv/
.vscode/
_docs/

# OS generated files
.DS_Store
Thumbs.db

# IDE files
/.idea/
/.vscode/
.cursorignore

# PHPUnit, Pest, and other test result files
.phpunit.result.cache
/.phpunit.result.cache
/tests/_output/
/tests/_support/_generated/
/coverage/

# User-specific files (temporary, experimental, to be archived / removed)
archived/
experimental/*
vendor/
.cursorignore
.env
composer.lock
php_errors.log
phpstan.neon
xdebug.log
tmp/
12 changes: 12 additions & 0 deletions bin/instructor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
DIR="$(dirname "$0")"
SCRIPT="$1"

# Sanity check
if [[ "$SCRIPT" =~ \.\. ]] || [[ ! "$SCRIPT" =~ ^[a-zA-Z0-9_-]+$ ]]; then
echo "Invalid script name."
exit 1
fi

shift
php "$DIR/../scripts/$SCRIPT.php" "$@"
13 changes: 13 additions & 0 deletions bin/instructor.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@echo off
set DIR=%~dp0
set SCRIPT=%1

:: Sanity check
echo %SCRIPT% | findstr /R /C:"\.\." /C:"[^a-zA-Z0-9_-]" >nul
if %ERRORLEVEL% neq 1 (
echo Invalid script name.
exit /b 1
)

shift
php "%DIR%..\scripts\%SCRIPT%.php" %*
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
"keywords": ["llm", "language models", "inference", "ai", "genai", "openai", "anthropic", "cohere", "ollama", "structured output", "semantic processing", "automation", "data processing", "data extraction"],
"type": "library",
"license": "MIT",
"bin": [
"bin/instructor"
],
"autoload": {
"psr-4": {
"Cognesy\\Instructor\\": "src/"
Expand All @@ -15,9 +18,11 @@
"psr-4": {
"Tests\\": "tests/",
"Examples\\": "examples/",
"Cognesy\\InstructorHub\\": "src-hub/",
"Cognesy\\Evals\\": "evals/",
"Cognesy\\Experimental\\": "experimental/"
"Cognesy\\Experimental\\": "experimental/",
"Cognesy\\InstructorHub\\": "src-hub/",
"Cognesy\\Setup\\": "src-setup/",
"Cognesy\\Tell\\": "src-tell/"
},
"files": [
"tests/Examples/Call/test_functions.php"
Expand All @@ -38,7 +43,6 @@
"gioni06/gpt3-tokenizer": "^1.2",
"guzzlehttp/psr7": "^2.7",
"illuminate/database": "^11.10",
"illuminate/events": "^11.10",
"league/html-to-markdown": "^5.1",
"mockery/mockery": "^1.6",
"nyholm/psr7": "^1.8",
Expand All @@ -47,10 +51,9 @@
"phpstan/phpstan": "^1.11",
"psr/http-factory-implementation": "*",
"psy/psysh": "@stable",
"spatie/array-to-xml": "^3.3",
"spatie/browsershot": "^4.1",
"spatie/php-structure-discoverer": "^2.1",
"symfony/browser-kit": "^7.1",
"symfony/console": "^7.1",
"symfony/css-selector": "^7.1",
"symfony/dom-crawler": "^7.1",
"symfony/http-client": "^7.1",
Expand Down Expand Up @@ -79,7 +82,6 @@
"phpstan/phpdoc-parser": "^1.29",
"psr/event-dispatcher": "^1.0",
"psr/log": "^3.0",
"spatie/yaml-front-matter": "^2.0",
"symfony/intl": "^7.1",
"symfony/property-access": "^6.4 || ^7.0",
"symfony/property-info": "^6.4 || ^7.0",
Expand All @@ -92,6 +94,6 @@
"tests": "@php vendor/bin/pest",
"phpstan": "@php vendor/bin/phpstan -c phpstan.neon",
"psalm": "@php vendor/bin/psalm",
"hub": "@php ./hub.php"
"instructor": "bash ./bin/instructor"
}
}
74 changes: 48 additions & 26 deletions config/prompt.php
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
<?php
return [
'defaultSetting' => 'twig',

'settings' => [
'twig' => [
'templateType' => 'twig',
'resourcePath' => '/../../../../prompts/twig',
'cachePath' => '/tmp/instructor/cache/twig',
'extension' => '.twig',
'frontMatterTags' => ['{#---', '---#}'],
'frontMatterFormat' => 'yaml',
'metadata' => [
'autoReload' => true,
],
],
'blade' => [
'templateType' => 'blade',
'resourcePath' => '/../../../../prompts/blade',
'cachePath' => '/tmp/instructor/cache/blade',
'extension' => '.blade.php',
'frontMatterTags' => ['{{--', '--}}'],
'frontMatterFormat' => 'yaml',
],
]
];
<?php
return [
'defaultLibrary' => 'demo-twig',

'libraries' => [
'system' => [
'templateEngine' => 'twig',
'resourcePath' => '/../../../../prompts/system',
'cachePath' => '/tmp/instructor/cache/system',
'extension' => '.twig',
'frontMatterTags' => ['{#---', '---#}'],
'frontMatterFormat' => 'yaml',
'metadata' => [
'autoReload' => true,
],
],
'demo-twig' => [
'templateEngine' => 'twig',
'resourcePath' => '/../../../../prompts/demo-twig',
'cachePath' => '/tmp/instructor/cache/twig',
'extension' => '.twig',
'frontMatterTags' => ['{#---', '---#}'],
'frontMatterFormat' => 'yaml',
'metadata' => [
'autoReload' => true,
],
],
'demo-blade' => [
'templateEngine' => 'blade',
'resourcePath' => '/../../../../prompts/demo-blade',
'cachePath' => '/tmp/instructor/cache/blade',
'extension' => '.blade.php',
'frontMatterTags' => ['{{--', '--}}'],
'frontMatterFormat' => 'yaml',
],
'examples' => [
'templateEngine' => 'twig',
'resourcePath' => '/../../../../prompts/examples',
'cachePath' => '/tmp/instructor/cache/examples',
'extension' => '.twig',
'frontMatterTags' => ['{#---', '---#}'],
'frontMatterFormat' => 'yaml',
'metadata' => [
'autoReload' => true,
],
],
]
];
Loading

0 comments on commit 3f74074

Please sign in to comment.