Skip to content

Commit

Permalink
Merge pull request #12 from FabricLabs/feature/v0.2.0-RC2
Browse files Browse the repository at this point in the history
0.2.0 RC2
  • Loading branch information
martindale authored Dec 10, 2024
2 parents 371af54 + a98f5c0 commit 6ba09a2
Show file tree
Hide file tree
Showing 86 changed files with 2,424 additions and 1,319 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dist: focal
language: node_js
node_js:
- 18.19.0
- 18.19.1
before_install:
- npm install -g codecov
after_success:
Expand Down
33 changes: 17 additions & 16 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
# Install Guide
## All Platforms
Sensemaker requires Node, MySQL, and Redis to run.
Sensemaker requires Node, MySQL, Redis, and Ollama to run. Install scripts are included in the `scripts/` directory, including `install.sh` to automate installation on a compatible system.

### Key Management
```
export FABRIC_SEED="some 24-word seed"
```
**Windows Users:** there is a known issue installing the TensorFlow dependency: https://github.com/tensorflow/tfjs/issues/7341

### Database Setup
```
MySQL is used as a reliable database for Sensemaker.

Open shell:
```bash
sudo mysql
```

In the MySQL shell:
```
```sql
CREATE DATABASE db_sensemaker;
CREATE USER 'db_user_sensemaker'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON db_sensemaker.* TO 'db_user_sensemaker'@'localhost';
EXIT;
```
Be sure to set a password in the commands above.

Install Knex, Seed Database
```
#### Knex
Knex is used to manage database schemas.

Install `knex`:
```bash
npm i -g knex # schema management tool
knex migrate:latest # create tables
knex seed:run # insert data
knex seed:run # initial data
```

### Ollama
Ollama is a convenient API provider for LLM interactions.

```
Run the install scripts:
```bash
./scripts/install-ollama.sh
./scripts/install-models.sh
```

Run dependencies with docker-compose (optional)
```
docker-compose up -d
```
Other models can be installed using `ollama pull <model-name>` and configured in `settings/local.js` in the `ollama` property.

## Debian/Ubuntu
```
Expand Down
10 changes: 7 additions & 3 deletions actions/accountActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

const { fetchFromAPI } = require('./apiActions');

async function fetchUsersFromAPI(token) {
async function fetchAccountsFromAPI (token) {
// TODO: pagination
return fetchFromAPI('/accounts', null, token);
}

async function fetchUsersFromAPI (token) {
// TODO: pagination
return fetchFromAPI('/users', null, token);
}
Expand Down Expand Up @@ -93,7 +98,6 @@ const askPasswordReset = (email) => {
};
}


module.exports = {
fetchUser,
fetchUsers,
Expand All @@ -106,5 +110,5 @@ module.exports = {
FETCH_ACCOUNTS_FAILURE,
PASSWORD_RESET_REQUEST,
PASSWORD_RESET_SUCCESS,
PASSWORD_RESET_FAILURE,
PASSWORD_RESET_FAILURE
};
13 changes: 3 additions & 10 deletions actions/chatActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,13 @@ const resetChat = (message) => {
};
}

const submitMessage = (message, collection_id = null, file_fabric_id = null) => {
const submitMessage = (message, collection_id = null) => {
return async (dispatch, getState) => {
dispatch(messageRequest());
const token = getState().auth.token;

try {
let requestBody = { ...message };
if (file_fabric_id !== null) {
requestBody.file_fabric_id = file_fabric_id;
}

const response = await fetch('/messages', {
method: 'POST',
headers: {
Expand Down Expand Up @@ -106,7 +102,7 @@ const fetchResponse = (message) => {
};
};

const regenAnswer = (message, collection_id = null, file_fabric_id = null) => {
const regenAnswer = (message, collection_id = null) => {
return async (dispatch, getState) => {
dispatch(messageRequest());
const token = getState().auth.token;
Expand All @@ -116,10 +112,6 @@ const regenAnswer = (message, collection_id = null, file_fabric_id = null) => {

// Start with the original message
let requestBody = { ...message };
// If file_id is not null, add it to the requestBody
if (file_fabric_id !== null) {
requestBody.file_fabric_id = file_fabric_id;
}

try {
const response = await fetch(`/messages/${message.id}`, {
Expand Down Expand Up @@ -152,6 +144,7 @@ const getMessages = (params = {}) => {
const state = getState();
const token = state.auth.token;

// TODO: re-evaluate this... is this safe?
if (!params.conversation_id) params.conversation_id = state.chat.message.conversation;

try {
Expand Down
97 changes: 97 additions & 0 deletions actions/groupActions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
'use strict';

const fetch = require('cross-fetch');
const { fetchFromAPI } = require('./apiActions');

async function fetchGroupsFromAPI (token) {
// TODO: pagination
return fetchFromAPI('/groups', null, token);
}

// Action types
const CREATE_GROUP_REQUEST = 'CREATE_GROUP_REQUEST';
const CREATE_GROUP_SUCCESS = 'CREATE_GROUP_SUCCESS';
const CREATE_GROUP_FAILURE = 'CREATE_GROUP_FAILURE';

const FETCH_GROUPS_REQUEST = 'FETCH_GROUPS_REQUEST';
const FETCH_GROUPS_SUCCESS = 'FETCH_GROUPS_SUCCESS';
const FETCH_GROUPS_FAILURE = 'FETCH_GROUPS_FAILURE';

const FETCH_GROUP_REQUEST = 'FETCH_GROUP_REQUEST';
const FETCH_GROUP_SUCCESS = 'FETCH_GROUP_SUCCESS';
const FETCH_GROUP_FAILURE = 'FETCH_GROUP_FAILURE';

// Action creators
const createGroupRequest = () => ({ type: CREATE_GROUP_REQUEST, loading: true });
const createGroupSuccess = (groups) => ({ type: CREATE_GROUP_SUCCESS, payload: groups, loading: false });
const createGroupFailure = (error) => ({ type: CREATE_GROUP_FAILURE, payload: error, loading: false });

const fetchGroupsRequest = () => ({ type: FETCH_GROUPS_REQUEST, loading: true });
const fetchGroupsSuccess = (groups) => ({ type: FETCH_GROUPS_SUCCESS, payload: groups, loading: false });
const fetchGroupsFailure = (error) => ({ type: FETCH_GROUPS_FAILURE, payload: error, loading: false });

const fetchGroupRequest = () => ({ type: FETCH_GROUP_REQUEST, loading: true });
const fetchGroupSuccess = (instance) => ({ type: FETCH_GROUP_SUCCESS, payload: instance, loading: false });
const fetchGroupFailure = (error) => ({ type: FETCH_GROUP_FAILURE, payload: error, loading: false });

// Thunk action creator
const fetchGroups = () => {
return async (dispatch, getState) => {
dispatch(fetchGroupsRequest());
const { token } = getState().auth;
try {
const groups = await fetchGroupsFromAPI(token);
dispatch(fetchGroupsSuccess(groups));
} catch (error) {
dispatch(fetchGroupsFailure(error));
}
};
};

const fetchGroup = (id) => {
return async (dispatch, getState) => {
dispatch(fetchGroupRequest());
const { token } = getState().auth;
try {
const instance = await fetchFromAPI(`/groups/${id}`, null, token);
dispatch(fetchGroupSuccess(instance));
} catch (error) {
dispatch(fetchGroupFailure(error));
}
};
};

const createGroup = (group) => {
return async (dispatch, getState) => {
dispatch(createGroupRequest());
const { token } = getState().auth;
try {
const newGroup = await fetch('/groups', {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(group)
});
dispatch(createGroupSuccess(newGroup));
} catch (error) {
dispatch(createGroupFailure(error));
}
};
}

module.exports = {
fetchGroup,
fetchGroups,
createGroup,
CREATE_GROUP_REQUEST,
CREATE_GROUP_SUCCESS,
CREATE_GROUP_FAILURE,
FETCH_GROUP_REQUEST,
FETCH_GROUP_SUCCESS,
FETCH_GROUP_FAILURE,
FETCH_GROUPS_REQUEST,
FETCH_GROUPS_SUCCESS,
FETCH_GROUPS_FAILURE
};
27 changes: 27 additions & 0 deletions actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,24 @@ const {
fetchUserFiles,
} = require('../actions/fileActions');

const {
fetchGroup,
fetchGroups,
createGroup
} = require('../actions/groupActions');

const {
fetchPeer,
fetchPeers,
createPeer
} = require('../actions/peerActions');

const {
fetchSource,
fetchSources,
createSource
} = require('../actions/sourceActions');

// ## Upload Actions
const {
fetchUploads,
Expand Down Expand Up @@ -179,6 +197,11 @@ module.exports = {
fetchFiles: fetchFiles,
fetchFile: fetchFile,
uploadFile: uploadFile,
fetchGroup: fetchGroup,
fetchGroups: fetchGroups,
createGroup: createGroup,
createPeer: createPeer,
createSource: createSource,
fetchUserFiles: fetchUserFiles,
fetchInquiry: fetchInquiry,
fetchInquiries: fetchInquiries,
Expand All @@ -193,9 +216,13 @@ module.exports = {
acceptInvitation: acceptInvitation,
declineInvitation: declineInvitation,
deleteInvitation: deleteInvitation,
fetchPeer: fetchPeer,
fetchPeers: fetchPeers,
fetchPeople: fetchPeople,
fetchPerson: fetchPerson,
fetchResponse: fetchResponse,
fetchSource: fetchSource,
fetchSources: fetchSources,
fetchTask: fetchTask,
fetchTasks: fetchTasks,
fetchUploads,
Expand Down
Loading

0 comments on commit 6ba09a2

Please sign in to comment.