Skip to content

Commit

Permalink
Merge branch 'master-COLLAUDO' into features-nov24/errors-fix-coll1
Browse files Browse the repository at this point in the history
# Conflicts:
#	package-lock.json
#	package.json
#	routes/files.js
#	routes/kb.js
  • Loading branch information
Giovanni Troisi committed Nov 21, 2024
2 parents f259637 + 30d8556 commit fb71c71
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 14 deletions.
4 changes: 4 additions & 0 deletions models/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ const TransactionSchema = mongoose.Schema({
type: String,
required: false
},
broadcast: {
type: Boolean,
required: false
},
createdAt: {
type: Date,
default: Date.now
Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,6 @@ router.post('/signup',
if (!skipVerificationEmail) {

let verify_email_code = uniqid();
console.log("(Auth) verify_email_code: ", verify_email_code);

let redis_client = req.app.get('redis_client');
let key = "emailverify:verify-" + verify_email_code;
let obj = { _id: savedUser._id, email: savedUser.email}
Expand Down
4 changes: 1 addition & 3 deletions routes/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ curl -u [email protected]:123456 \
*/

router.post('/users', [passport.authenticate(['basic', 'jwt'], { session: false }), validtoken], upload.single('file'), (req, res, next) => {

console.log("asdasd")
winston.info("files/users")
winston.verbose("files/users")
return res.status(201).json({
message: 'File uploded successfully',
filename: req.file.filename
Expand Down
5 changes: 3 additions & 2 deletions services/openaiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,13 @@ class OpenaiService {
}

getContentChunks(namespace_id, content_id, engine) {
winston.info("[OPENAI SERVICE] kb endpoint: " + kb_endpoint_train);
winston.info(kb_endpoint_train + "/id/" + content_id + "/namespace/" + namespace_id)
winston.debug("[OPENAI SERVICE] kb endpoint: " + kb_endpoint_train);
winston.verbose(kb_endpoint_train + "/id/" + content_id + "/namespace/" + namespace_id)
return new Promise((resolve, reject) => {

let payload = { engine: engine };
let token = jwt.sign(payload, secret);
console.log("token: ", token)
axios({
url: kb_endpoint_train + "/id/" + content_id + "/namespace/" + namespace_id + "/" + token,
headers: {
Expand Down
54 changes: 54 additions & 0 deletions test/faqkbRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,60 @@ describe('FaqKBRoute', () => {

})

it('get-all-chatbots-with-chatbot-token', (done) => {

var email = "test-signup-" + Date.now() + "@email.com";
var pwd = "pwd";

userService.signup(email, pwd, "Test Firstname", "Test lastname").then(function (savedUser) {
projectService.create("test-faqkb-create", savedUser._id).then(function (savedProject) {

chai.request(server)
.post('/' + savedProject._id + '/faq_kb')
.auth(email, pwd)
.send({ "name": "testbot", type: "external", language: 'fr' })
.end((err, res) => {

if (err) { console.error("err: ", err); }
if (log) { console.log("res.body", res.body); }

res.should.have.status(200);
res.body.should.be.a('object');

let id_faq_kb = res.body._id;

chai.request(server)
.get('/' + savedProject._id + '/faq_kb/' + id_faq_kb + '/jwt')
.auth(email, pwd)
.end((err, res) => {

if (err) { console.error("err: ", err); }
console.log("chatbot token", res.body);
let chatbot_token = res.body.jwt;

chai.request(server)
.get('/' + savedProject._id + '/faq_kb/')
.set('Authorization', 'JWT ' + chatbot_token)
.end((err, res) => {

if (err) { console.error("err: ", err); }
console.log("res.body", res.body);

res.should.have.status(200);

done();

});


})

});
});
});

})

it('create-new-chatbot-agent-role', (done) => {

var email = "test-signup-" + Date.now() + "@email.com";
Expand Down
3 changes: 2 additions & 1 deletion test/kbRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,7 @@ describe('KbRoute', () => {

if (err) { console.error("err: ", err); }
if (log) { console.log("get all namespaces res.body: ", res.body); }

console.log("get all namespaces res.body: ", res.body);
res.should.have.status(200);
res.body.should.be.a('array');
expect(res.body.length).to.equal(1);
Expand Down Expand Up @@ -1816,6 +1816,7 @@ describe('KbRoute', () => {
})
}).timeout(10000)


/**
* Delete namespace
* !! Unable to test it due to external request
Expand Down

0 comments on commit fb71c71

Please sign in to comment.