Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion forge/db/controllers/Assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = {
isTeamOnTrial = undefined
}) => {
const timeout = app.config.assistant?.service?.requestTimeout || 60000
const serviceUrl = app.config.assistant?.service?.url
const serviceUrl = app.config.assistant?.service?.url || 'https://expert.flowfuse/v1/openai'
const url = `${serviceUrl.replace(/\/+$/, '')}/${method.replace(/^\/+/, '')}`

const headers = await module.exports.buildRequestHeaders(app, additionalHeaders, {
Expand Down
2 changes: 1 addition & 1 deletion forge/expert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { LRUCache } = require('lru-cache')
module.exports = fp(async function (app, _opts) {
// Get the assistant service configuration
const serviceEnabled = app.config.expert?.enabled === true
const expertUrl = app.config.expert?.service?.url
const expertUrl = app.config.expert?.service?.url || 'https://expert.flowfuse/v4/expert'
const serviceToken = app.config.expert?.service?.token
const requestTimeout = app.config.expert?.service?.requestTimeout || 60000

Expand Down
2 changes: 1 addition & 1 deletion forge/routes/api/assistant.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = async function (app) {
app.decorate('assistant', { assetCache, tablesSchemaCache })

// Get the assistant service configuration
const serviceUrl = app.config.assistant?.service?.url
const serviceUrl = app.config.assistant?.service?.url || 'https://expert.flowfuse/v1/openai'
const serviceToken = app.config.assistant?.service?.token
const serviceEnabled = app.config.assistant?.enabled !== false && serviceUrl
const requestTimeout = app.config.assistant?.service?.requestTimeout || 60000
Expand Down
24 changes: 12 additions & 12 deletions test/unit/forge/routes/api/assistant_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ describe('Assistant API', async function () {
})
response.statusCode.should.equal(501)
})
it('should return 501 if assistant service url is not set', async function () {
app2 = await setupApp({ assistant: { enabled: true, service: { url: null } } })
const instance = app2.project
const token = (await instance.refreshAuthTokens()).token
const response = await app2.inject({
method: 'POST',
url: '/api/v1/assistant/function',
headers: { authorization: 'Bearer ' + token },
payload: { prompt: 'multiply by 5', transactionId: '1234' }
})
response.statusCode.should.equal(501)
})
// it('should return 501 if assistant service url is not set', async function () {
// app2 = await setupApp({ assistant: { enabled: true, service: { url: null } } })
// const instance = app2.project
// const token = (await instance.refreshAuthTokens()).token
// const response = await app2.inject({
// method: 'POST',
// url: '/api/v1/assistant/function',
// headers: { authorization: 'Bearer ' + token },
// payload: { prompt: 'multiply by 5', transactionId: '1234' }
// })
// response.statusCode.should.equal(501)
// })
})

describe('service enabled', async function () {
Expand Down
24 changes: 12 additions & 12 deletions test/unit/forge/routes/api/expert_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1497,17 +1497,17 @@ describe('Expert API', function () {
})
response.statusCode.should.equal(501)
})
it('should return 501 if expert service url is not set', async function () {
app = await setupApp({ expert: { enabled: true, service: { url: null } } })
const instance = app.project
const token = (await instance.refreshAuthTokens()).token
const response = await app.inject({
method: 'POST',
url: '/api/v1/expert/chat',
headers: { authorization: 'Bearer ' + token },
payload: { context: { team: 'teamid' }, query: 'test' }
})
response.statusCode.should.equal(501)
})
// it('should return 501 if expert service url is not set', async function () {
// app = await setupApp({ expert: { enabled: true, service: { url: null } } })
// const instance = app.project
// const token = (await instance.refreshAuthTokens()).token
// const response = await app.inject({
// method: 'POST',
// url: '/api/v1/expert/chat',
// headers: { authorization: 'Bearer ' + token },
// payload: { context: { team: 'teamid' }, query: 'test' }
// })
// response.statusCode.should.equal(501)
// })
})
})
Loading