Skip to content

Commit 73507a2

Browse files
committed
improve error message
1 parent 4ec78ec commit 73507a2

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Service/Agent/Sender.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,14 @@ public function send(int $agentId, AgentInput $input, ContextInterface $context)
8080
throw new StatusCode\NotFoundException('Could not find provided agent');
8181
}
8282

83-
$agent = $this->connector->getConnection($row->getConnectionId());
83+
$connectionId = $row->getConnectionId();
84+
if (empty($connectionId)) {
85+
throw new StatusCode\InternalServerErrorException('No agent connection was configured, please create first an agent connection to a LLM provider like ChatGPT or Ollama in order to use an agent');
86+
}
87+
88+
$agent = $this->connector->getConnection($connectionId);
8489
if (!$agent instanceof AgentInterface) {
85-
throw new StatusCode\InternalServerErrorException('Could not resolve agent connection, please create first an agent connection to a LLM provider like ChatGPT or Ollama');
90+
throw new StatusCode\InternalServerErrorException('Provided an invalid connection, the connection must be an agent connection');
8691
}
8792

8893
$chatId = $input->getPreviousId();

0 commit comments

Comments
 (0)