-
-
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
Open
Remg
wants to merge
8
commits into
master
Choose a base branch
from
chatbot-v2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Chatbot v2 #9656
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
91b2086
[Chatbot] Refactor
Remg 5b6ef48
Fix admin
Remg 639afbc
Multiple fixes
Remg ba70197
Add assistant relation to message
Remg d9b80fd
Refactor MessageFactory
Remg d14f452
Add OpenAI Assistant ID validation
Remg 31ecb14
OpenAiId is unique
Remg 35ed72f
Use variable instead of same call
Remg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,8 +76,20 @@ framework: | |
exchange: { name: 'messenger-topic', type: 'topic', default_publish_routing_key: 'chatbot' } | ||
queues: | ||
chatbot: { binding_keys: [ 'chatbot' ] } | ||
telegram: | ||
dsn: "%env(RABBITMQ_DSN)%" | ||
retry_strategy: | ||
max_retries: 10 | ||
delay: 3000 | ||
multiplier: 1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is the default value |
||
options: | ||
exchange: { name: 'messenger-topic', type: 'topic', default_publish_routing_key: 'telegram' } | ||
queues: | ||
telegram: { binding_keys: [ 'telegram' ] } | ||
|
||
routing: | ||
App\Chatbot\Command\RefreshThreadCommand: chatbot | ||
App\OpenAI\Command\RunThreadCommand: chatbot | ||
App\Telegram\Command\SendBotMessageCommand: telegram | ||
App\Mailchimp\CampaignMessageInterface: mailchimp_campaign | ||
App\Mailchimp\SynchronizeMessageInterface: mailchimp_sync | ||
App\Pap\Command\AsynchronousMessageInterface: pap | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,6 +8,7 @@ services: | |||||||||||||||
public: false | ||||||||||||||||
bind: | ||||||||||||||||
$environment: "%kernel.environment%" | ||||||||||||||||
$webhookProxyHost: "%env(WEBHOOK_PROXY_HOST)%" | ||||||||||||||||
|
||||||||||||||||
App\DataFixtures\: | ||||||||||||||||
resource: '../src/DataFixtures/' | ||||||||||||||||
|
@@ -26,10 +27,6 @@ services: | |||||||||||||||
|
||||||||||||||||
App\Ohme\ClientInterface: '@Tests\App\Ohme\DummyClient' | ||||||||||||||||
|
||||||||||||||||
Tests\App\Chatbot\Provider\DummyProvider: ~ | ||||||||||||||||
|
||||||||||||||||
App\Chatbot\Provider\ProviderInterface: '@Tests\App\Chatbot\Provider\DummyProvider' | ||||||||||||||||
|
||||||||||||||||
App\Mandrill\EmailClient: | ||||||||||||||||
class: 'Tests\App\Test\Mailer\NullEmailClient' | ||||||||||||||||
|
||||||||||||||||
|
@@ -51,3 +48,14 @@ services: | |||||||||||||||
|
||||||||||||||||
Kreait\Firebase\Contract\DynamicLinks: '@Tests\App\Test\Firebase\DummyDynamicLinks' | ||||||||||||||||
Kreait\Firebase\Contract\Messaging: '@Tests\App\Test\Firebase\DummyMessaging' | ||||||||||||||||
|
||||||||||||||||
Tests\App\OpenAI\Client\Client: ~ | ||||||||||||||||
App\OpenAI\Client\ClientInterface: '@Tests\App\OpenAI\Client\Client' | ||||||||||||||||
|
||||||||||||||||
Tests\App\Telegram\Client\ClientFactory: ~ | ||||||||||||||||
App\Telegram\Client\ClientFactoryInterface: '@Tests\App\Telegram\Client\ClientFactory' | ||||||||||||||||
|
||||||||||||||||
App\Telegram\Webhook\UrlGenerator: ~ | ||||||||||||||||
Tests\App\Telegram\Webhook\ProxyUrlGenerator: | ||||||||||||||||
decorates: App\Telegram\Webhook\UrlGenerator | ||||||||||||||||
arguments: ['@.inner'] | ||||||||||||||||
Comment on lines
+58
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Suggested change
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,214 @@ | ||
<?php | ||
|
||
namespace Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240205225155 extends AbstractMigration | ||
{ | ||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('CREATE TABLE openai_assistant ( | ||
id INT UNSIGNED AUTO_INCREMENT NOT NULL, | ||
created_by_administrator_id INT DEFAULT NULL, | ||
updated_by_administrator_id INT DEFAULT NULL, | ||
name VARCHAR(255) NOT NULL, | ||
open_ai_id VARCHAR(255) NOT NULL, | ||
uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', | ||
created_at DATETIME NOT NULL, | ||
updated_at DATETIME NOT NULL, | ||
UNIQUE INDEX UNIQ_55C6718E5E237E06 (name), | ||
UNIQUE INDEX UNIQ_55C6718EF6E32D4D (open_ai_id), | ||
UNIQUE INDEX UNIQ_55C6718ED17F50A6 (uuid), | ||
INDEX IDX_55C6718E9DF5350C (created_by_administrator_id), | ||
INDEX IDX_55C6718ECF1918FF (updated_by_administrator_id), | ||
PRIMARY KEY(id) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('CREATE TABLE telegram_bot ( | ||
id INT UNSIGNED AUTO_INCREMENT NOT NULL, | ||
created_by_administrator_id INT DEFAULT NULL, | ||
updated_by_administrator_id INT DEFAULT NULL, | ||
name VARCHAR(255) NOT NULL, | ||
enabled TINYINT(1) DEFAULT 0 NOT NULL, | ||
api_token VARCHAR(255) NOT NULL, | ||
secret VARCHAR(255) NOT NULL, | ||
blacklisted_ids LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:simple_array)\', | ||
whitelisted_ids LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:simple_array)\', | ||
uuid CHAR(36) NOT NULL COMMENT \'(DC2Type:uuid)\', | ||
created_at DATETIME NOT NULL, | ||
updated_at DATETIME NOT NULL, | ||
UNIQUE INDEX UNIQ_CED6A3DF5E237E06 (name), | ||
UNIQUE INDEX UNIQ_CED6A3DF7BA2F5EB (api_token), | ||
UNIQUE INDEX UNIQ_CED6A3DF5CA2E8E5 (secret), | ||
UNIQUE INDEX UNIQ_CED6A3DFD17F50A6 (uuid), | ||
INDEX IDX_CED6A3DF9DF5350C (created_by_administrator_id), | ||
INDEX IDX_CED6A3DFCF1918FF (updated_by_administrator_id), | ||
PRIMARY KEY(id) | ||
) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE | ||
openai_assistant | ||
ADD | ||
CONSTRAINT FK_55C6718E9DF5350C FOREIGN KEY (created_by_administrator_id) REFERENCES administrators (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('ALTER TABLE | ||
openai_assistant | ||
ADD | ||
CONSTRAINT FK_55C6718ECF1918FF FOREIGN KEY (updated_by_administrator_id) REFERENCES administrators (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('ALTER TABLE | ||
telegram_bot | ||
ADD | ||
CONSTRAINT FK_CED6A3DF9DF5350C FOREIGN KEY (created_by_administrator_id) REFERENCES administrators (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('ALTER TABLE | ||
telegram_bot | ||
ADD | ||
CONSTRAINT FK_CED6A3DFCF1918FF FOREIGN KEY (updated_by_administrator_id) REFERENCES administrators (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('DROP INDEX UNIQ_7DC4B00477153098 ON chatbot'); | ||
$this->addSql('ALTER TABLE | ||
chatbot | ||
ADD | ||
open_ai_assistant_id INT UNSIGNED DEFAULT NULL, | ||
ADD | ||
telegram_bot_id INT UNSIGNED DEFAULT NULL, | ||
ADD | ||
name VARCHAR(255) NOT NULL, | ||
ADD | ||
type VARCHAR(255) NOT NULL, | ||
ADD | ||
assistant_type VARCHAR(255) NOT NULL, | ||
DROP | ||
code, | ||
DROP | ||
assistant_id, | ||
DROP | ||
enabled, | ||
DROP | ||
telegram_bot_api_token, | ||
DROP | ||
telegram_bot_secret'); | ||
$this->addSql('ALTER TABLE | ||
chatbot | ||
ADD | ||
CONSTRAINT FK_7DC4B0043FF15E50 FOREIGN KEY (open_ai_assistant_id) REFERENCES openai_assistant (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('ALTER TABLE | ||
chatbot | ||
ADD | ||
CONSTRAINT FK_7DC4B004A0E2F38 FOREIGN KEY (telegram_bot_id) REFERENCES telegram_bot (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_7DC4B0045E237E06 ON chatbot (name)'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_7DC4B0043FF15E50 ON chatbot (open_ai_assistant_id)'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_7DC4B004A0E2F38 ON chatbot (telegram_bot_id)'); | ||
$this->addSql('ALTER TABLE | ||
chatbot_message | ||
ADD | ||
assistant_id INT UNSIGNED DEFAULT NULL, | ||
ADD | ||
run_id INT UNSIGNED DEFAULT NULL, | ||
ADD | ||
entities JSON NOT NULL, | ||
CHANGE | ||
content text LONGTEXT NOT NULL, | ||
CHANGE | ||
external_id open_ai_id VARCHAR(255) DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE | ||
chatbot_message | ||
ADD | ||
CONSTRAINT FK_EDF1E884E05387EF FOREIGN KEY (assistant_id) REFERENCES openai_assistant (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('ALTER TABLE | ||
chatbot_message | ||
ADD | ||
CONSTRAINT FK_EDF1E88484E3FEC4 FOREIGN KEY (run_id) REFERENCES chatbot_run (id) ON DELETE | ||
SET | ||
NULL'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_EDF1E884F6E32D4D ON chatbot_message (open_ai_id)'); | ||
$this->addSql('CREATE INDEX IDX_EDF1E884E05387EF ON chatbot_message (assistant_id)'); | ||
$this->addSql('CREATE INDEX IDX_EDF1E88484E3FEC4 ON chatbot_message (run_id)'); | ||
$this->addSql('ALTER TABLE | ||
chatbot_run | ||
ADD | ||
open_ai_id VARCHAR(255) DEFAULT NULL, | ||
CHANGE | ||
external_id open_ai_status VARCHAR(255) DEFAULT NULL'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_D603CBB6F6E32D4D ON chatbot_run (open_ai_id)'); | ||
$this->addSql('ALTER TABLE chatbot_thread CHANGE external_id open_ai_id VARCHAR(255) DEFAULT NULL'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_A356AA3CF6E32D4D ON chatbot_thread (open_ai_id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE chatbot DROP FOREIGN KEY FK_7DC4B0043FF15E50'); | ||
$this->addSql('ALTER TABLE chatbot_message DROP FOREIGN KEY FK_EDF1E884E05387EF'); | ||
$this->addSql('ALTER TABLE chatbot DROP FOREIGN KEY FK_7DC4B004A0E2F38'); | ||
$this->addSql('ALTER TABLE openai_assistant DROP FOREIGN KEY FK_55C6718E9DF5350C'); | ||
$this->addSql('ALTER TABLE openai_assistant DROP FOREIGN KEY FK_55C6718ECF1918FF'); | ||
$this->addSql('ALTER TABLE telegram_bot DROP FOREIGN KEY FK_CED6A3DF9DF5350C'); | ||
$this->addSql('ALTER TABLE telegram_bot DROP FOREIGN KEY FK_CED6A3DFCF1918FF'); | ||
$this->addSql('DROP TABLE openai_assistant'); | ||
$this->addSql('DROP TABLE telegram_bot'); | ||
$this->addSql('DROP INDEX UNIQ_7DC4B0045E237E06 ON chatbot'); | ||
$this->addSql('DROP INDEX UNIQ_7DC4B0043FF15E50 ON chatbot'); | ||
$this->addSql('DROP INDEX UNIQ_7DC4B004A0E2F38 ON chatbot'); | ||
$this->addSql('ALTER TABLE | ||
chatbot | ||
ADD | ||
code VARCHAR(255) NOT NULL, | ||
ADD | ||
assistant_id VARCHAR(255) NOT NULL, | ||
ADD | ||
enabled TINYINT(1) DEFAULT 0 NOT NULL, | ||
ADD | ||
telegram_bot_api_token VARCHAR(255) DEFAULT NULL, | ||
ADD | ||
telegram_bot_secret VARCHAR(255) DEFAULT NULL, | ||
DROP | ||
open_ai_assistant_id, | ||
DROP | ||
telegram_bot_id, | ||
DROP | ||
name, | ||
DROP | ||
type, | ||
DROP | ||
assistant_type'); | ||
$this->addSql('CREATE UNIQUE INDEX UNIQ_7DC4B00477153098 ON chatbot (code)'); | ||
$this->addSql('ALTER TABLE chatbot_message DROP FOREIGN KEY FK_EDF1E88484E3FEC4'); | ||
$this->addSql('DROP INDEX UNIQ_EDF1E884F6E32D4D ON chatbot_message'); | ||
$this->addSql('DROP INDEX IDX_EDF1E884E05387EF ON chatbot_message'); | ||
$this->addSql('DROP INDEX IDX_EDF1E88484E3FEC4 ON chatbot_message'); | ||
$this->addSql('ALTER TABLE | ||
chatbot_message | ||
DROP | ||
assistant_id, | ||
DROP | ||
run_id, | ||
DROP | ||
entities, | ||
CHANGE | ||
text content LONGTEXT NOT NULL, | ||
CHANGE | ||
open_ai_id external_id VARCHAR(255) DEFAULT NULL'); | ||
$this->addSql('DROP INDEX UNIQ_D603CBB6F6E32D4D ON chatbot_run'); | ||
$this->addSql('ALTER TABLE | ||
chatbot_run | ||
ADD | ||
external_id VARCHAR(255) DEFAULT NULL, | ||
DROP | ||
open_ai_status, | ||
DROP | ||
open_ai_id'); | ||
$this->addSql('DROP INDEX UNIQ_A356AA3CF6E32D4D ON chatbot_thread'); | ||
$this->addSql('ALTER TABLE chatbot_thread CHANGE open_ai_id external_id VARCHAR(255) DEFAULT NULL'); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?