Skip to content

Commit 4217e81

Browse files
committed
PR Reviewed
1 parent b94864d commit 4217e81

File tree

3 files changed

+16
-31
lines changed

3 files changed

+16
-31
lines changed

bot/engine/src/main/kotlin/engine/config/RAGAnswerHandler.kt

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,7 @@ object RAGAnswerHandler : AbstractProactiveAnswerHandler {
7272
if (noAnswerStory == null && answer != null) {
7373
logger.info { "Send RAG answer." }
7474

75-
val publicTraceUrl = observabilityInfo?.let {
76-
// Get observability configuration
77-
val observabilityConfig = botDefinition.observabilityConfiguration
78-
// If observability configuration exists and contain a public URL, replace the trace URL
79-
if (observabilityConfig?.enabled == true && observabilityConfig.setting is LangfuseObservabilitySetting<*>) {
80-
val publicUrl = (observabilityConfig.setting as LangfuseObservabilitySetting<*>).publicUrl
81-
if (!publicUrl.isNullOrBlank()) {
82-
it.traceUrl.replace(
83-
(observabilityConfig.setting as LangfuseObservabilitySetting<*>).url,
84-
publicUrl
85-
)
86-
} else {
87-
it.traceUrl
88-
}
89-
} else {
90-
it.traceUrl
91-
}
92-
}
93-
94-
// Modified ObservabilityInfo
95-
val modifiedObservabilityInfo = observabilityInfo?.let {
96-
ObservabilityInfo(
97-
traceId = it.traceId,
98-
traceName = it.traceName,
99-
traceUrl = publicTraceUrl ?: it.traceUrl
100-
)
101-
}
75+
val modifiedObservabilityInfo = observabilityInfo?.let { updateObservabilityInfo(this, it) }
10276

10377
send(
10478
SendSentenceWithFootnotes(
@@ -120,6 +94,20 @@ object RAGAnswerHandler : AbstractProactiveAnswerHandler {
12094
}
12195
}
12296

97+
private fun updateObservabilityInfo(botBus: BotBus, info: ObservabilityInfo): ObservabilityInfo {
98+
val config = botBus.botDefinition.observabilityConfiguration
99+
if (config?.enabled == true && config.setting is LangfuseObservabilitySetting<*>) {
100+
val setting = config.setting as LangfuseObservabilitySetting<*>
101+
// Stockage dans une variable locale pour éviter le smart cast impossible sur une propriété déclarée dans un autre module
102+
val publicUrl = setting.publicUrl
103+
if (!publicUrl.isNullOrBlank()) {
104+
// Remplace l'URL interne par l'URL publique configurée
105+
return info.copy(traceUrl = info.traceUrl.replace(setting.url, publicUrl))
106+
}
107+
}
108+
return info
109+
}
110+
123111
/**
124112
* Manage story redirection when no answer redirection is filled
125113
* Use the handler of the configured story otherwise launch default unknown story

gen-ai/orchestrator-core/src/main/kotlin/ai/tock/genai/orchestratorcore/mappers/ObservabilitySettingMapper.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object ObservabilitySettingMapper {
5454
when (this) {
5555
is LangfuseObservabilitySetting -> {
5656
val secretKey = SecurityUtils.createSecretKey(namespace, botId, feature, secretKey)
57-
return LangfuseObservabilitySetting(secretKey, publicKey, url, publicUrl)
57+
return LangfuseObservabilitySetting(secretKey, publicKey, url, publicUrl.takeIf {!it.isNullOrBlank()})
5858
}
5959
else ->
6060
throw IllegalArgumentException("Unsupported Observability Setting")

gen-ai/orchestrator-server/src/main/python/server/src/gen_ai_orchestrator/routers/responses/responses.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ class ObservabilityInfo(BaseModel):
118118
trace_url: str = Field(
119119
description='The observability trace url.'
120120
)
121-
public_trace_url: Optional[str] = Field(
122-
None, description="The public observability trace url."
123-
)
124121

125122
class RagResponse(BaseModel):
126123
"""The RAG response model"""

0 commit comments

Comments
 (0)