-
-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chatbot v2 #9656
base: master
Are you sure you want to change the base?
Chatbot v2 #9656
Conversation
87462a0
to
6db1b5b
Compare
860934f
to
3edf971
Compare
@@ -87,6 +87,7 @@ LEGISLATIVES_AVECVOUS_HOST=legislatives.avecvous.code | |||
RENAISSANCE_HOST=renaissance.code | |||
APP_RENAISSANCE_HOST=renaissance.code | |||
WEBHOOK_RENAISSANCE_HOST=webhook.renaissance.code | |||
WEBHOOK_PROXY_HOST= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be in .env.dev
file, no?
retry_strategy: | ||
max_retries: 10 | ||
delay: 3000 | ||
multiplier: 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the default value
App\Telegram\Webhook\UrlGenerator: ~ | ||
Tests\App\Telegram\Webhook\ProxyUrlGenerator: | ||
decorates: App\Telegram\Webhook\UrlGenerator | ||
arguments: ['@.inner'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Service UrlGenerator will be auto created by main service config and you can decorate it here
App\Telegram\Webhook\UrlGenerator: ~ | |
Tests\App\Telegram\Webhook\ProxyUrlGenerator: | |
decorates: App\Telegram\Webhook\UrlGenerator | |
arguments: ['@.inner'] | |
Tests\App\Telegram\Webhook\ProxyUrlGenerator: | |
decorates: App\Telegram\Webhook\UrlGenerator | |
arguments: ['@.inner'] |
public static function fromOpenAI(OpenAIRunStatusEnum $runStatus): self | ||
{ | ||
return match ($runStatus) { | ||
OpenAIRunStatusEnum::QUEUED => self::QUEUED, | ||
OpenAIRunStatusEnum::IN_PROGRESS => self::IN_PROGRESS, | ||
OpenAIRunStatusEnum::COMPLETED => self::COMPLETED, | ||
OpenAIRunStatusEnum::CANCELLING, OpenAIRunStatusEnum::CANCELLED => self::CANCELLED, | ||
OpenAIRunStatusEnum::REQUIRES_ACTION, OpenAIRunStatusEnum::EXPIRED, OpenAIRunStatusEnum::FAILED => self::FAILED, | ||
default => self::UNKNOWN | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about moving this method into OpenAIRunStatusEnum
to avoid to have all mappings in this class?
|
||
public function __construct(string $openAIApiKey) | ||
{ | ||
$this->openAI = \OpenAI::client($openAIApiKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about injecting this like a service in construct ?
public function handle(Request $request): JsonResponse | ||
{ | ||
if (!$secret = $request->headers->get(self::SECRET_TOKEN_HEADER)) { | ||
throw new BadRequestHttpException('The request has no secret token header.'); | ||
} | ||
|
||
if (!$bot = $this->botProvider->findOneEnabledBySecret($secret)) { | ||
throw new BadRequestHttpException('No bot found for given secret token.'); | ||
} | ||
|
||
$this->logger->log($bot, 'Received webhook request.'); | ||
|
||
if (!$content = $request->getContent()) { | ||
throw new BadRequestHttpException('No content in request'); | ||
} | ||
|
||
try { | ||
$data = BotApi::jsonValidate($content, true); | ||
} catch (InvalidJsonException $e) { | ||
throw new BadRequestHttpException('The request content is not a valid JSON payload.'); | ||
} | ||
|
||
try { | ||
$update = Update::fromResponse($data); | ||
} catch (InvalidArgumentException $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO all this stuff can be moved into TelegramBotController because it's too related to the HTTP request. Actually I can't use this handler from Sf Command but I can use UpdateHandler. Wdyt?
chatbot: | ||
type: | ||
telegram: Telegram | ||
assistant_type: | ||
openai: OpenAI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about making it in two lines ?
chatbot.type.telegram:
chatbot.assistant_type.openai:
it's easier to search when it's in one line
84ca694
to
cd499a6
Compare
No description provided.