Repository navigation
Conversation
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
…tion ID passed as an optional input field in the chat providers Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
Signed-off-by: Julien Veyssier <julien-nc@posteo.net>
|
Besides OpenCode Go, are there any other services that might be able to take advantage of or require this? Perhaps it would be safer to limit which headers can be sent, or do you think this approach is still fine? |
kyteinsky
left a comment
There was a problem hiding this comment.
maybe Summary, Translate, etc. tasks also need the conversation id injection since they use the same chat completion endpoint.
for opencode, they wouldn't work without the conversation id header.
| return header.name !== header.name.trim() | ||
| || header.value !== header.value.trim() |
There was a problem hiding this comment.
not sure if this works well for UX, if there is a genuine space after the header name/value, it will not be registered, maybe we can still register it trimmed?
if new edits to the field land, a new request can be made to save that.
wdyt?
| || this.headerNameInvalid(header.name) | ||
| || this.headerValueInvalid(header.value) |
There was a problem hiding this comment.
it might be good to show an error/red the input box if these fail so the user is aware there is a mistake
There was a problem hiding this comment.
ah this is already the case, maybe dirty header can be replaced with a debounce?
| $name = trim($header['name']); | ||
| if ($name !== '' && preg_match(ServiceConfig::HEADER_NAME_PATTERN, $name) !== 1) { |
There was a problem hiding this comment.
maybe empty header names can be rejected here too
| /** Characters an HTTP header name is made of (the RFC 7230 token) */ | ||
| public const HEADER_NAME_PATTERN = '/^[a-zA-Z0-9!#$%&\'*+.^_`|~-]+$/'; |
There was a problem hiding this comment.
perhaps the regex can be aligned with that of guzzle, especially the FIELD_VALUE_PATTERN one
https://github.com/guzzle/psr7/blob/a3059ba1a84c9139c4ae03cf0f45bea276c97c74/src/Rfc9110.php
https://github.com/guzzle/psr7/blob/a3059ba1a84c9139c4ae03cf0f45bea276c97c74/src/MessageTrait.php
| 'body' => $body, | ||
| 'content-type' => $contentTypeHeader, | ||
| ]; | ||
| } catch (ClientException|ServerException $e) { |
There was a problem hiding this comment.
\InvalidArgumentException can be thrown in the request too if headers are not valid, would be nice to catch them too here.
see the header regex link.
closes #436
refs #430
Some services might require extra headers like a non-standard authentication header.
{$conversation_id) in the header value. This variable is only resolved in chat providers. It resolves to theconversation_idoptional input that is sent by the assistant (see Let the chat providers know about the conversation/session ID assistant#674 ). This header will only be sent for chat requests.🤖 AI (if applicable)