diff --git a/README.md b/README.md index a642f6f..2af6ce1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/Ollama.php b/src/Ollama.php index 1684605..d2a88e0 100755 --- a/src/Ollama.php +++ b/src/Ollama.php @@ -21,6 +21,7 @@ class Ollama protected $options; protected $stream; protected $raw; + protected $agent; /** * Ollama class constructor. @@ -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. * @@ -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; }