|
1 | 1 | <!-- 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> |
2 | 11 | <div x-data="{ |
3 | 12 | isLoading: false, |
4 | 13 | error: null, |
|
95 | 104 | } |
96 | 105 | }, |
97 | 106 |
|
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 | | -
|
106 | 107 | getSessionId() { |
107 | 108 | let sessionId = sessionStorage.getItem('gordon-session-id') |
108 | 109 | if (!sessionId) { |
|
112 | 113 | return sessionId |
113 | 114 | }, |
114 | 115 |
|
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 | | -
|
123 | 116 | async streamGordonResponse(responseIndex) { |
124 | 117 |
|
125 | 118 | // Build API request from messages, excluding the streaming placeholder |
|
157 | 150 | ...(this.threadId && { thread_uuid: this.threadId }) |
158 | 151 | } |
159 | 152 |
|
160 | | - const response = await fetch(this.getGordonEndpoint(), { |
| 153 | + const response = await fetch(window.GORDON_BASE_URL + '/public/ask', { |
161 | 154 | method: 'POST', |
162 | 155 | headers: { 'Content-Type': 'application/json' }, |
163 | 156 | body: JSON.stringify(payload) |
|
253 | 246 | } |
254 | 247 |
|
255 | 248 | try { |
256 | | - const response = await fetch(this.getFeedbackEndpoint(), { |
| 249 | + const response = await fetch(window.GORDON_BASE_URL + '/feedback', { |
257 | 250 | method: 'POST', |
258 | 251 | headers: { 'Content-Type': 'application/json' }, |
259 | 252 | body: JSON.stringify({ |
|
0 commit comments