Skip to content

Commit

Permalink
Add agent
Browse files Browse the repository at this point in the history
  • Loading branch information
Toni authored and Toni committed Nov 20, 2023
1 parent 1c300f3 commit e66a0ee
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ return [
```php
use Cloudstudio\Ollama\Facades\Ollama;

$response = Ollama::prompt('Why is the sky blue?')
$response = Ollama::agent('You are a weather expert...')
->prompt('Why is the sky blue?')
->model('llama2')
->options(['temperature' => 0.8])
->stream(false)
Expand Down
15 changes: 14 additions & 1 deletion src/Ollama.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Ollama
protected $options;
protected $stream;
protected $raw;
protected $agent;

/**
* Ollama class constructor.
Expand All @@ -32,6 +33,18 @@ public function __construct(ModelService $modelService)
$this->options = [];
}

/**
* Sets the agent for generation.
*
* @param string $agent
* @return $this
*/
public function agent(string $agent)
{
$this->agent = $agent;
return $this;
}

/**
* Sets the prompt for generation.
*
Expand All @@ -40,7 +53,7 @@ public function __construct(ModelService $modelService)
*/
public function prompt(string $prompt)
{
$this->prompt = $prompt;
$this->prompt = $this->agent ? $this->agent . ' ' . $prompt : $prompt;
return $this;
}

Expand Down

0 comments on commit e66a0ee

Please sign in to comment.