Skip to content

Commit a9651d1

Browse files
committed
site(gordon): configure hostname with HUGO_USE_LOCAL_GORDON
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
1 parent f54f6db commit a9651d1

1 file changed

Lines changed: 11 additions & 18 deletions

File tree

layouts/partials/gordon-chat.html

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
<!-- Gordon AI Chat Panel -->
2+
<script>
3+
window.GORDON_BASE_URL = {{ if eq hugo.Environment "production" -}}
4+
'https://ai-backend-service.docker.com'
5+
{{- else if getenv "HUGO_GORDON_URL" -}}
6+
'{{ getenv "HUGO_GORDON_URL" }}'
7+
{{- else -}}
8+
'https://ai-backend-service-stage.docker.com'
9+
{{- end }};
10+
</script>
211
<div x-data="{
312
isLoading: false,
413
error: null,
@@ -95,14 +104,6 @@
95104
}
96105
},
97106
98-
getGordonEndpoint() {
99-
const endpoints = {
100-
'docs.docker.com': 'https://ai-backend-service.docker.com/public/ask',
101-
'localhost': 'http://localhost:8000/public/ask'
102-
}
103-
return endpoints[window.location.hostname] || 'https://ai-backend-service-stage.docker.com/public/ask'
104-
},
105-
106107
getSessionId() {
107108
let sessionId = sessionStorage.getItem('gordon-session-id')
108109
if (!sessionId) {
@@ -112,14 +113,6 @@
112113
return sessionId
113114
},
114115
115-
getFeedbackEndpoint() {
116-
const endpoints = {
117-
'docs.docker.com': 'https://ai-backend-service.docker.com/feedback',
118-
'localhost': 'http://localhost:8000/feedback'
119-
}
120-
return endpoints[window.location.hostname] || 'https://ai-backend-service-stage.docker.com/feedback'
121-
},
122-
123116
async streamGordonResponse(responseIndex) {
124117
125118
// Build API request from messages, excluding the streaming placeholder
@@ -157,7 +150,7 @@
157150
...(this.threadId && { thread_uuid: this.threadId })
158151
}
159152
160-
const response = await fetch(this.getGordonEndpoint(), {
153+
const response = await fetch(window.GORDON_BASE_URL + '/public/ask', {
161154
method: 'POST',
162155
headers: { 'Content-Type': 'application/json' },
163156
body: JSON.stringify(payload)
@@ -253,7 +246,7 @@
253246
}
254247
255248
try {
256-
const response = await fetch(this.getFeedbackEndpoint(), {
249+
const response = await fetch(window.GORDON_BASE_URL + '/feedback', {
257250
method: 'POST',
258251
headers: { 'Content-Type': 'application/json' },
259252
body: JSON.stringify({

0 commit comments

Comments
 (0)