role; } /** * Returns the question of the chatbot. * @return string The question of the chatbot. */ public function getQuestion(){ return $this->question; } /** * Returns the context of the chatbot. * @return string The context of the chatbot. */ public function getContext(){ return $this->context; } /** * Returns whether the context is allowed in the prompt. * @return bool True if context is allowed, false otherwise. */ public function getContextAllowness(){ return $this->allowContext; } /** * Sets the role of the chatbot. * @param string $role The role to set for the chatbot. */ public function setRole($role){ $this->role = $role; } /** * Sets the question for the chatbot. * @param string $question The question to set for the chatbot. */ public function setQuestion($question){ $this->question = $question; } /** * Sets the context for the chatbot. * @param string $context The context to set for the chatbot. */ public function setContext($context){ //TODO: Better context handling in order to bypass token limits // Maybe require an Array of context items? (MCP Like?) $this->context = $context; } /** * Sets whether the context is allowed in the prompt. * @param bool $allowContext True to allow context, false to disallow. */ public function setContextAllowness($allowContext){ $this->allowContext = $allowContext; } /** * Builds the prompt string for the chatbot. * This includes the role, context (if allowed), and question. * @return string The complete prompt string. */ public function buildPromptString(){ $prompt = "Deine Rolle ist: " . $this->role; if ($this->allowContext) { $prompt .= "\nDu hast folgenden Kontext, auf den du dich NUR fokussierst: " . $this->context; } $prompt .= "\nDies ist die Frage des Nutzers: " . $this->question; $prompt .= "\nBeantworte die Frage so gut es geht\n"; return $prompt; } /** * Builds the prompt data for API requests. * This includes the model, messages (role, question, context), and other parameters. * @return string JSON encoded prompt data. */ public function buildPromptData(){ $messages = [ ["role" => "system", "content" => $this->getRole()], ["role" => "user", "content" => $this->getQuestion()], ]; // add context if allowed if ($this->allowContext) { $messages[] = ["role" => "context", "content" => $this->getContext()]; } return json_encode([ "model" => "deepseek-llm-7b-chat", "messages" => $messages, "temperature" => 0.5, "max_tokens" => -1, "stream" => false ]); } }