-
Notifications
You must be signed in to change notification settings - Fork 136
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
[DERCBOT-1267] Gen AI - Document Compressor #1788
base: master
Are you sure you want to change the base?
[DERCBOT-1267] Gen AI - Document Compressor #1788
Conversation
cd83089
to
84e3c63
Compare
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.
Thanks for adding all the check document compressor settings to the orchestrator 👍️, juste a small comment about an exception raising that could be improved.
We begin to have a lot of Gen AI related configuration directly on the Bot Definition, I'm not sure but in a futur refactory I might be a good option to group them especially if we want to expose the to python scripted stories (tock-py) and also kotlin scripted stories. It would be great to have access to some BotDefinition configurations inside buildin sotries (stories behind the Bot API). Maybe we should create an issue about that.
My idea is in a near futur to expose Gen AI settings to build in stories (especially python, tock-py ones) so that python developpers could easily build there own langchain chains using the bot settings and the gen-ai-orchestrator factories provided in a separated python package.
We also have a lot of gen ai related configuration endpoint directly on the bot admin verticle we should in the futur group them in a different verticle.
@@ -6,6 +6,7 @@ | |||
<option name="PARENT_ENVS" value="true" /> | |||
<envs> | |||
<env name="PYTHONUNBUFFERED" value="1" /> | |||
<env name="REQUESTS_CA_BUNDLE" value="/etc/ssl/certs/ca-certificates.crt" /> |
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 shouldn't be committed here, put it in a dot env file instead.
cause=f'Response: {response.text}, Reason: {response.reason}', | ||
request=f'[POST] {url}', | ||
)) | ||
except Exception as exc: |
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.
Here you will catch the already formatted exception inside the try block at L80 as GenAIDocumentCompressorErrorException inherits from Exception. This will lead to a wrapping of the exception inside an other GenAIDocumentCompressorErrorException object which is a bit strange and will make it difficult to handle it.
Instead you can do the following :
except GenAIDocumentCompressorErrorException:
# Re-raise GenAIDocumentCompressorErrorException without modification
raise
except Exception as exc:
# Catch all other exceptions
logger.error(f'Unknown error ! {exc}')
raise GenAIDocumentCompressorErrorException(ErrorInfo(
error=exc.__class__.__name__,
cause=str(exc),
request=f'[POST] {url}',
))
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.
yes, absolutely
class BaseDocumentCompressorSetting(BaseModel): | ||
provider: DocumentCompressorProvider = Field( | ||
description='The document compressor provider.', | ||
examples=[DocumentCompressorProvider.BLOOMZ], |
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.
It's a bit late for this comment but I think that all document compressor will have max_documents
and min_score
but we only have one kind of compressor for now so can't be sure this refactoring could still be done in the futur if we add other kind of compressors.
package ai.tock.genai.orchestratorcore.models.compressor | ||
|
||
data class BloomzDocumentCompressorSetting( | ||
val maxDocuments: Int, |
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.
It's optional on the orchestrator side but we can make it required at the bot api / bot admin level. Same for label.
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.
it is already required for Tock Studio, botApi and botAdmin
@@ -35,6 +37,7 @@ object Constants { | |||
|
|||
const val GEN_AI_COMPLETION_SENTENCE_GENERATION="$GEN_AI_COMPLETION/sentenceGeneration" | |||
|
|||
const val GEN_AI_COMPRESSION="$GEN_AI/COMPRESSION" |
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.
Is it used somewhere ? Or is it for futur use in case we have a compressor with secrets ?
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.
yes, I'm going to delete it, it's not in use now.
@@ -26,6 +26,8 @@ object Constants { | |||
const val OPEN_SEARCH = "OpenSearch" | |||
const val PG_VECTOR = "PGVector" | |||
|
|||
const val BLOOMZ = "BloomzRerank" |
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.
Bloomz can also be used a retriever / embedding model and also as guardrail model, this contant should have a more explicit name indicating that this is the compressor type.
Please don't apply the suggestion do a refactoring using an IDE.
const val BLOOMZ = "BloomzRerank" | |
const val BLOOMZ_COMPRESSOR = "BloomzRerank" |
bot/admin/server/src/main/kotlin/service/ObservabilityValidationService.kt
Show resolved
Hide resolved
84e3c63
to
ea378c3
Compare
Yes, we need to include it in the analysis when we refactor the orchestrator code. We need to put this in a separate ticket. |
98d7c19
to
c9f9ccb
Compare
c9f9ccb
to
1a917bf
Compare
This pull request adds support for a new Document Compressor feature in the bot administration service. The changes include adding new data models, services, and API endpoints to manage the Document Compressor configuration. Additionally, some existing code has been updated to integrate this new functionality.
Document Compressor Feature:
bot/admin/server/src/main/kotlin/BotAdminService.kt
: AddedBotDocumentCompressorConfigurationDAO
and implemented methods to delete the Document Compressor configuration. [1] [2] [3]bot/admin/server/src/main/kotlin/BotAdminVerticle.kt
: Added new API endpoints to handle CRUD operations for the Document Compressor configuration.bot/admin/server/src/main/kotlin/model/BotDocumentCompressorConfigurationDTO.kt
: Created a new data transfer object for the Document Compressor configuration.bot/admin/server/src/main/kotlin/service/DocumentCompressorService.kt
: Implemented the service to manage Document Compressor configurations, including validation and error handling.bot/admin/server/src/main/kotlin/service/DocumentCompressorValidationService.kt
: Added a validation service to check the Document Compressor configuration settings.Other Changes:
bot/connector-rest-client/src/main/kotlin/model/ClientFootnote.kt
andbot/connector-web-model/src/main/kotlin/ai/tock/bot/connector/web/send/Footnote.kt
: Added a newscore
field to theFootnote
data class. [1] [2]bot/connector-web/src/main/kotlin/WebMessageProcessor.kt
andbot/connector-web/src/test/kotlin/WebConnectorResponseTest.kt
: Updated theWebMessageProcessor
and its test to handle the newscore
field inFootnote
. [1] [2]bot/engine/src/main/kotlin/admin/bot/compressor/BotDocumentCompressorConfiguration.kt
andbot/engine/src/main/kotlin/admin/bot/compressor/BotDocumentCompressorConfigurationDAO.kt
: Added new data models and DAO interfaces for the Document Compressor configuration. [1] [2]bot/engine/src/main/kotlin/definition/BotDefinition.kt
andbot/engine/src/main/kotlin/definition/BotDefinitionBase.kt
: Updated theBotDefinition
andBotDefinitionBase
to include the Document Compressor configuration. [1] [2] [3] [4]bot/engine/src/main/kotlin/engine/BotRepository.kt
: Added import forBotDocumentCompressorConfigurationMonitor
.