Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: replace eslint with the biome for formatting and linting changes #14

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/eslint.yml

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Lint

on:
push:
branches: [main]
pull_request:

jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install packages
run: npm install
- name: Run the lint
run: npm run lint
65 changes: 32 additions & 33 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ When a prompt has Slack's special syntax like <@USER_ID> or <#CHANNEL_ID>, you m

const assistant = new Assistant({
/**
* (Recommended) A custom ThreadContextStore can be provided, inclusive of methods to
* get and save thread context. When provided, these methods will override the `getThreadContext`
* and `saveThreadContext` utilities that are made available in other Assistant event listeners.
*/
* (Recommended) A custom ThreadContextStore can be provided, inclusive of methods to
* get and save thread context. When provided, these methods will override the `getThreadContext`
* and `saveThreadContext` utilities that are made available in other Assistant event listeners.
*/
// threadContextStore: {
// get: async ({ context, client, payload }) => {},
// save: async ({ context, client, payload }) => {},
// },

/**
* `assistant_thread_started` is sent when a user opens the Assistant container.
* This can happen via DM with the app or as a side-container within a channel.
* https://api.slack.com/events/assistant_thread_started
*/
* `assistant_thread_started` is sent when a user opens the Assistant container.
* This can happen via DM with the app or as a side-container within a channel.
* https://api.slack.com/events/assistant_thread_started
*/
threadStarted: async ({ event, say, setSuggestedPrompts, saveThreadContext }) => {
const { context } = event.assistant_thread;

Expand All @@ -53,12 +53,15 @@ const assistant = new Assistant({

await saveThreadContext();

const prompts = [{
title: 'This is a suggested prompt',
message: 'When a user clicks a prompt, the resulting prompt message text can be passed '
+ 'directly to your LLM for processing.\n\nAssistant, please create some helpful prompts '
+ 'I can provide to my users.',
}];
const prompts = [
{
title: 'This is a suggested prompt',
message:
'When a user clicks a prompt, the resulting prompt message text can be passed ' +
'directly to your LLM for processing.\n\nAssistant, please create some helpful prompts ' +
'I can provide to my users.',
},
];

// If the user opens the Assistant container in a channel, additional
// context is available.This can be used to provide conditional prompts
Expand All @@ -83,12 +86,12 @@ const assistant = new Assistant({
},

/**
* `assistant_thread_context_changed` is sent when a user switches channels
* while the Assistant container is open. If `threadContextChanged` is not
* provided, context will be saved using the AssistantContextStore's `save`
* method (either the DefaultAssistantContextStore or custom, if provided).
* https://api.slack.com/events/assistant_thread_context_changed
*/
* `assistant_thread_context_changed` is sent when a user switches channels
* while the Assistant container is open. If `threadContextChanged` is not
* provided, context will be saved using the AssistantContextStore's `save`
* method (either the DefaultAssistantContextStore or custom, if provided).
* https://api.slack.com/events/assistant_thread_context_changed
*/
threadContextChanged: async ({ saveThreadContext }) => {
// const { channel_id, thread_ts, context: assistantContext } = event.assistant_thread;
try {
Expand All @@ -99,10 +102,10 @@ const assistant = new Assistant({
},

/**
* Messages sent to the Assistant do not contain a subtype and must
* be deduced based on their shape and metadata (if provided).
* https://api.slack.com/events/message
*/
* Messages sent to the Assistant do not contain a subtype and must
* be deduced based on their shape and metadata (if provided).
* https://api.slack.com/events/message
*/
userMessage: async ({ client, message, getThreadContext, say, setTitle, setStatus }) => {
const { channel, thread_ts } = message;

Expand All @@ -123,7 +126,7 @@ const assistant = new Assistant({
/** Scenario 1: Handle suggested prompt selection
* The example below uses a prompt that relies on the context (channel) in which
* the user has asked the question (in this case, to summarize that channel).
*/
*/
if (message.text === 'Assistant, please summarize the activity in this channel!') {
const threadContext = await getThreadContext();
let channelHistory;
Expand All @@ -149,9 +152,9 @@ const assistant = new Assistant({

// Prepare and tag the prompt and messages for LLM processing
let llmPrompt = `Please generate a brief summary of the following messages from Slack channel <#${threadContext.channel_id}:`;
channelHistory.messages.reverse().forEach((m) => {
for (const m of channelHistory.messages.reverse()) {
if (m.user) llmPrompt += `\n<@${m.user}> says: ${m.text}`;
});
}

const messages = [
{ role: 'system', content: DEFAULT_SYSTEM_CONTENT },
Expand All @@ -173,7 +176,7 @@ const assistant = new Assistant({

/**
* Scenario 2: Format and pass user messages directly to the LLM
*/
*/

// Retrieve the Assistant thread history for context of question being asked
const thread = await client.conversations.replies({
Expand All @@ -189,11 +192,7 @@ const assistant = new Assistant({
return { role, content: m.text };
});

const messages = [
{ role: 'system', content: DEFAULT_SYSTEM_CONTENT },
...threadHistory,
userMessage,
];
const messages = [{ role: 'system', content: DEFAULT_SYSTEM_CONTENT }, ...threadHistory, userMessage];

// Send message history and newest question to LLM
const llmResponse = await openai.chat.completions.create({
Expand Down
32 changes: 32 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"formatter": {
"enabled": true,
"formatWithErrors": false,
"ignore": [],
"attributePosition": "auto",
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 120,
"lineEnding": "lf"
},
"javascript": {
"formatter": {
"quoteStyle": "single"
}
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"organizeImports": {
"enabled": true
},
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
}
}
86 changes: 43 additions & 43 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{
"display_information": {
"name": "Bolt for JavaScript Assistant"
"display_information": {
"name": "Bolt for JavaScript Assistant"
},
"features": {
"app_home": {
"home_tab_enabled": false,
"messages_tab_enabled": true,
"messages_tab_read_only_enabled": false
},
"features": {
"app_home": {
"home_tab_enabled": false,
"messages_tab_enabled": true,
"messages_tab_read_only_enabled": false
},
"bot_user": {
"display_name": "Bolt for JavaScript Assistant",
"always_online": false
},
"assistant_view": {
"assistant_description": "An Assistant built with Bolt for JavaScript, at your service!",
"suggested_prompts": []
}
"bot_user": {
"display_name": "Bolt for JavaScript Assistant",
"always_online": false
},
"oauth_config": {
"scopes": {
"bot": [
"assistant:write",
"channels:join",
"im:history",
"channels:history",
"groups:history",
"chat:write"
]
}
},
"settings": {
"event_subscriptions": {
"bot_events": [
"assistant_thread_context_changed",
"assistant_thread_started",
"message.im"
]
},
"interactivity": {
"is_enabled": false
},
"org_deploy_enabled": false,
"socket_mode_enabled": true,
"token_rotation_enabled": false
"assistant_view": {
"assistant_description": "An Assistant built with Bolt for JavaScript, at your service!",
"suggested_prompts": []
}
},
"oauth_config": {
"scopes": {
"bot": [
"assistant:write",
"channels:join",
"im:history",
"channels:history",
"groups:history",
"chat:write"
]
}
}
},
"settings": {
"event_subscriptions": {
"bot_events": [
"assistant_thread_context_changed",
"assistant_thread_started",
"message.im"
]
},
"interactivity": {
"is_enabled": false
},
"org_deploy_enabled": false,
"socket_mode_enabled": true,
"token_rotation_enabled": false
}
}
Loading