Skip to content

Commit

Permalink
Fix model copy method and stream option in Ollama class, refactor sys…
Browse files Browse the repository at this point in the history
…tem prompt.

Fix readme typo
  • Loading branch information
Toni authored and Toni committed Dec 4, 2023
1 parent e66a0ee commit 7346603
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $response = Ollama::model('Llama2')->show();
### Copy a Model

```php
Ollama::model('Llama2')->copy('newDestination');
Ollama::model('Llama2')->copy('NewModel');
```

### Delete a Model
Expand Down
10 changes: 5 additions & 5 deletions src/Ollama.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Ollama
protected $prompt;
protected $format;
protected $options;
protected $stream;
protected $stream = false;
protected $raw;
protected $agent;

Expand All @@ -30,7 +30,6 @@ public function __construct(ModelService $modelService)
{
$this->modelService = $modelService;
$this->model = config('ollama.model');
$this->options = [];
}

/**
Expand All @@ -53,7 +52,7 @@ public function agent(string $agent)
*/
public function prompt(string $prompt)
{
$this->prompt = $this->agent ? $this->agent . ' ' . $prompt : $prompt;
$this->prompt = $prompt;
return $this;
}

Expand Down Expand Up @@ -88,7 +87,7 @@ public function format(string $format)
* @param array $options
* @return $this
*/
public function options(array $options)
public function options(array $options = [])
{
$this->options = $options;
return $this;
Expand All @@ -100,7 +99,7 @@ public function options(array $options)
* @param bool $stream
* @return $this
*/
public function stream(bool $stream)
public function stream(bool $stream = false)
{
$this->stream = $stream;
return $this;
Expand Down Expand Up @@ -196,6 +195,7 @@ public function ask()
{
return $this->sendRequest('/api/generate', [
'model' => $this->model,
'system' => $this->agent,
'prompt' => $this->prompt,
'format' => $this->format,
'options' => $this->options,
Expand Down

0 comments on commit 7346603

Please sign in to comment.