-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Toni
authored and
Toni
committed
Nov 19, 2023
0 parents
commit 08046f3
Showing
17 changed files
with
696 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{yml,yaml}] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Path-based git attributes | ||
# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html | ||
|
||
# Ignore all test and documentation with "export-ignore". | ||
/.github export-ignore | ||
/.gitattributes export-ignore | ||
/.gitignore export-ignore | ||
/phpunit.xml.dist export-ignore | ||
/art export-ignore | ||
/docs export-ignore | ||
/tests export-ignore | ||
/workbench export-ignore | ||
/.editorconfig export-ignore | ||
/.php_cs.dist.php export-ignore | ||
/psalm.xml export-ignore | ||
/psalm.xml.dist export-ignore | ||
/testbench.yaml export-ignore | ||
/UPGRADING.md export-ignore | ||
/phpstan.neon.dist export-ignore | ||
/phpstan-baseline.neon export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.idea | ||
.phpunit.cache | ||
build | ||
composer.lock | ||
coverage | ||
docs | ||
phpunit.xml | ||
phpstan.neon | ||
testbench.yaml | ||
vendor | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Changelog | ||
|
||
All notable changes to `ollama-laravel` will be documented in this file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) cloudstudio <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
|
||
# Ollama-Laravel Package | ||
|
||
Ollama-Laravel is a Laravel package providing seamless integration with the Ollama API. It includes functionalities for model management, prompt generation, format setting, and more. This package is perfect for developers looking to leverage the power of the Ollama API in their Laravel applications. | ||
|
||
## Installation | ||
|
||
```bash | ||
composer require cloudstudio/ollama-laravel | ||
``` | ||
|
||
## Configuration | ||
|
||
```bash | ||
php artisan vendor:publish --tag="ollama-laravel-config" | ||
``` | ||
|
||
Published config file: | ||
|
||
```php | ||
return [ | ||
'model' => env('OLLAMA_MODEL', 'llama2'), | ||
'url' => env('OLLAMA_URL', 'http://127.0.0.1:11434'), | ||
'default_prompt' => env('OLLAMA_DEFAULT_PROMPT', 'Hello, how can I assist you today?'), | ||
'connection' => [ | ||
'timeout' => env('OLLAMA_CONNECTION_TIMEOUT', 300), | ||
], | ||
]; | ||
``` | ||
|
||
## Usage | ||
|
||
### Basic Usage | ||
|
||
```php | ||
use Cloudstudio\Ollama\Facades\Ollama; | ||
|
||
$response = Ollama::prompt('Why is the sky blue?') | ||
->model('llama2') | ||
->options(['temperature' => 0.8]) | ||
->stream(false) | ||
->ask(); | ||
``` | ||
|
||
### Show Model Information | ||
|
||
```php | ||
$response = Ollama::model('Llama2')->show(); | ||
``` | ||
|
||
### Copy a Model | ||
|
||
```php | ||
Ollama::model('Llama2')->copy('newDestination'); | ||
``` | ||
|
||
### Delete a Model | ||
|
||
```php | ||
Ollama::model('Llama2')->delete(); | ||
``` | ||
|
||
### Generate Embeddings | ||
|
||
```php | ||
$embeddings = Ollama::model('Llama2')->embeddings('Your prompt here'); | ||
``` | ||
|
||
## Testing | ||
|
||
```bash | ||
pest | ||
``` | ||
|
||
## Changelog, Contributing, and Security | ||
|
||
- [Changelog](CHANGELOG.md) | ||
- [Contributing](CONTRIBUTING.md) | ||
|
||
## Credits | ||
|
||
- [Toni Soriano](https://github.com/cloudstudio) | ||
|
||
## License | ||
|
||
[MIT License](LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"name": "cloudstudio/ollama-laravel", | ||
"description": "This is my package ollama-laravel", | ||
"keywords": [ | ||
"cloudstudio", | ||
"laravel", | ||
"ollama-laravel" | ||
], | ||
"homepage": "https://github.com/cloudstudio/ollama-laravel", | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Toni Soriano", | ||
"email": "[email protected]", | ||
"role": "Developer" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"spatie/laravel-package-tools": "^1.14.0", | ||
"illuminate/contracts": "^10.0" | ||
}, | ||
"require-dev": { | ||
"laravel/pint": "^1.0", | ||
"nunomaduro/collision": "^7.8", | ||
"orchestra/testbench": "^8.8", | ||
"pestphp/pest": "^2.20", | ||
"pestphp/pest-plugin-arch": "^2.0", | ||
"pestphp/pest-plugin-laravel": "^2.0" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Cloudstudio\\Ollama\\": "src/", | ||
"Cloudstudio\\Ollama\\Database\\Factories\\": "database/factories/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Cloudstudio\\Ollama\\Tests\\": "tests/", | ||
"Workbench\\App\\": "workbench/app/" | ||
} | ||
}, | ||
"scripts": { | ||
"post-autoload-dump": "@composer run prepare", | ||
"clear": "@php vendor/bin/testbench package:purge-ollama-laravel --ansi", | ||
"prepare": "@php vendor/bin/testbench package:discover --ansi", | ||
"build": [ | ||
"@composer run prepare", | ||
"@php vendor/bin/testbench workbench:build --ansi" | ||
], | ||
"start": [ | ||
"Composer\\Config::disableProcessTimeout", | ||
"@composer run build", | ||
"@php vendor/bin/testbench serve" | ||
], | ||
"analyse": "vendor/bin/phpstan analyse", | ||
"test": "vendor/bin/pest", | ||
"test-coverage": "vendor/bin/pest --coverage", | ||
"format": "vendor/bin/pint" | ||
}, | ||
"config": { | ||
"sort-packages": true, | ||
"allow-plugins": { | ||
"pestphp/pest-plugin": true, | ||
"phpstan/extension-installer": true | ||
} | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Cloudstudio\\Ollama\\OllamaServiceProvider" | ||
], | ||
"aliases": { | ||
"Ollama": "Cloudstudio\\Ollama\\Facades\\Ollama" | ||
} | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
// Config for Cloudstudio/Ollama | ||
|
||
return [ | ||
'model' => env('OLLAMA_MODEL', 'llama2'), | ||
'url' => env('OLLAMA_URL', 'http://127.0.0.1:11434'), | ||
'default_prompt' => env('OLLAMA_DEFAULT_PROMPT', 'Hello, how can I assist you today?'), | ||
'connection' => [ | ||
'timeout' => env('OLLAMA_CONNECTION_TIMEOUT', 300), | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" | ||
backupGlobals="false" | ||
bootstrap="vendor/autoload.php" | ||
colors="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
executionOrder="random" | ||
failOnWarning="true" | ||
failOnRisky="true" | ||
failOnEmptyTestSuite="true" | ||
beStrictAboutOutputDuringTests="true" | ||
cacheDirectory=".phpunit.cache" | ||
backupStaticProperties="false" | ||
> | ||
<testsuites> | ||
<testsuite name="Cloudstudio Test Suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<coverage> | ||
<report> | ||
<html outputDirectory="build/coverage"/> | ||
<text outputFile="build/coverage.txt"/> | ||
<clover outputFile="build/logs/clover.xml"/> | ||
</report> | ||
</coverage> | ||
<logging> | ||
<junit outputFile="build/report.junit.xml"/> | ||
</logging> | ||
<source> | ||
<include> | ||
<directory suffix=".php">./src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Cloudstudio\Ollama\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
/** | ||
* @see \Cloudstudio\Ollama\Ollama | ||
*/ | ||
class Ollama extends Facade | ||
{ | ||
protected static function getFacadeAccessor() | ||
{ | ||
return \Cloudstudio\Ollama\Ollama::class; | ||
} | ||
} |
Oops, something went wrong.