-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
chore: added examples for bare and slack (#17)
- @callstack/slack-rich-text@0.8.1
- @callstack/slack-rich-text@0.8.0
- @callstack/slack-rich-text@0.7.0
- @callstack/slack-rich-text@0.6.0
- @callstack/slack-rich-text@0.5.0
- @callstack/document-loaders@0.8.1
- @callstack/document-loaders@0.8.0
- @callstack/document-loaders@0.7.0
- @callstack/document-loaders@0.6.0
- @callstack/document-loaders@0.5.0
- @callstack/byorg-utils@0.8.1
- @callstack/byorg-utils@0.8.0
- @callstack/byorg-utils@0.7.0
- @callstack/byorg-utils@0.6.0
- @callstack/byorg-utils@0.5.0
- @callstack/byorg-slack@0.8.1
- @callstack/byorg-slack@0.8.0
- @callstack/byorg-slack@0.7.0
- @callstack/byorg-slack@0.6.0
- @callstack/byorg-slack@0.5.0
- @callstack/byorg-discord@0.8.1
- @callstack/byorg-discord@0.8.0
- @callstack/byorg-discord@0.7.0
- @callstack/byorg-discord@0.6.0
- @callstack/byorg-discord@0.5.0
- @callstack/byorg-core@0.8.1
- @callstack/byorg-core@0.8.0
- @callstack/byorg-core@0.7.0
- @callstack/byorg-core@0.6.0
- @callstack/byorg-core@0.5.0
Showing
24 changed files
with
1,043 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'discord-example': minor | ||
'slack-example': minor | ||
'bare-example': minor | ||
--- | ||
|
||
Added example apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
rslib.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"root": true, | ||
"extends": ["@callstack/eslint-config/node", "prettier"], | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "bare-example", | ||
"version": "1.0.0", | ||
"description": "Example usage of byorg.ai core", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"source": "src/index.js", | ||
"private": true, | ||
"scripts": { | ||
"build": "rsbuild build", | ||
"example": "pnpm build && dotenv -- node dist/index.cjs" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/openai": "^1.0.2", | ||
"@callstack/byorg-core": "0.4.2", | ||
"@callstack/byorg-utils": "0.4.2" | ||
}, | ||
"devDependencies": { | ||
"dotenv-cli": "^7.4.2", | ||
"@callstack/eslint-config": "^14.2.0", | ||
"@rsbuild/core": "^1.0.5", | ||
"eslint": "^8.57.0", | ||
"prettier": "^3.3.3", | ||
"typescript": "^5.6.3" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
const shared = { | ||
source: { | ||
tsconfigPath: './tsconfig.build.json', | ||
}, | ||
}; | ||
|
||
export default defineConfig({ | ||
source: { | ||
entry: { | ||
index: { | ||
filename: 'index.cjs', | ||
import: './src/index.ts', | ||
}, | ||
}, | ||
tsconfigPath: './tsconfig.build.json', | ||
}, | ||
output: { | ||
target: 'node', | ||
minify: false, | ||
}, | ||
tools: { | ||
rspack: { | ||
module: { | ||
parser: { | ||
javascript: { | ||
dynamicImportMode: 'eager', | ||
}, | ||
}, | ||
}, | ||
resolve: { | ||
extensionAlias: { | ||
'.js': ['.js', '.ts'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import readline from 'readline'; | ||
import { Message, VercelChatModelAdapter, createApp } from '@callstack/byorg-core'; | ||
import { createOpenAI } from '@ai-sdk/openai'; | ||
import { requireEnv } from '@callstack/byorg-utils'; | ||
|
||
const LANGUAGE_MODEL = 'gpt-4o-2024-11-20'; | ||
const API_KEY = requireEnv('OPENAI_API_KEY'); | ||
|
||
const openAiProvider = createOpenAI({ | ||
apiKey: API_KEY, | ||
compatibility: 'strict', // strict mode, enable when using the OpenAI API | ||
}); | ||
|
||
const openAiModel = openAiProvider.languageModel(LANGUAGE_MODEL); | ||
|
||
const chatModel = new VercelChatModelAdapter({ | ||
languageModel: openAiModel, | ||
}); | ||
|
||
const SYSTEM_PROMPT = 'Your name is Byorg. You are an AI Assistant.'; | ||
|
||
const app = createApp({ | ||
chatModel, | ||
systemPrompt: () => SYSTEM_PROMPT, | ||
}); | ||
|
||
// Create a readline interface for user input | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
prompt: 'You: ', | ||
}); | ||
|
||
// Create array for messages | ||
const messages: Message[] = []; | ||
|
||
// Start the CLI chat | ||
console.log('Welcome to the byorg.ai example cli Chat!\n'); | ||
|
||
rl.prompt(); | ||
|
||
rl.on('line', async (line: string) => { | ||
const input = line.trim(); | ||
|
||
if (input.toLowerCase() === 'exit') { | ||
console.log('\nGoodbye!'); | ||
rl.close(); | ||
return; | ||
} | ||
|
||
messages.push({ role: 'user', content: input }); | ||
|
||
process.stdout.write('\n'); | ||
process.stdout.write('ai: '); | ||
|
||
let currentMessage = ''; | ||
const { response } = await app.processMessages(messages, { | ||
onPartialResponse: (text: string) => { | ||
const delta = text.slice(currentMessage.length); | ||
currentMessage += delta; | ||
process.stdout.write(delta); | ||
}, | ||
}); | ||
|
||
if (response.role === 'assistant') { | ||
messages.push({ role: response.role, content: response.content }); | ||
} | ||
|
||
process.stdout.write('\n\n'); | ||
|
||
rl.prompt(); | ||
|
||
return; | ||
}); | ||
|
||
process.on('SIGINT', () => { | ||
console.log('Exiting'); | ||
process.exit(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"noEmit": false, | ||
"paths": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "node16", | ||
"moduleResolution": "node16", | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noStrictGenericChecks": false, | ||
"skipLibCheck": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "react" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
rslib.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"root": true, | ||
"extends": ["@callstack/eslint-config/node", "prettier"], | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "discord-example", | ||
"version": "1.0.0", | ||
"description": "Example usage of byorg.ai discord integration", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"private": true, | ||
"bin": { | ||
"example": "./index.js" | ||
}, | ||
"scripts": { | ||
"build": "rsbuild build", | ||
"example": "pnpm build && dotenv -- node dist/index.cjs" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/openai": "^1.0.2", | ||
"@callstack/byorg-core": "0.4.2", | ||
"@callstack/byorg-discord": "0.4.2", | ||
"@callstack/byorg-utils": "0.4.2" | ||
}, | ||
"devDependencies": { | ||
"dotenv-cli": "^7.4.2", | ||
"@callstack/eslint-config": "^14.2.0", | ||
"@rsbuild/core": "^1.0.5", | ||
"eslint": "^8.57.0", | ||
"prettier": "^3.3.3", | ||
"typescript": "^5.6.3" | ||
}, | ||
"author": "", | ||
"license": "ISC" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
export default defineConfig({ | ||
source: { | ||
entry: { | ||
index: { | ||
filename: 'index.cjs', | ||
import: './src/index.ts', | ||
}, | ||
}, | ||
tsconfigPath: './tsconfig.build.json', | ||
}, | ||
output: { | ||
target: 'node', | ||
minify: false, | ||
}, | ||
tools: { | ||
rspack: { | ||
module: { | ||
parser: { | ||
javascript: { | ||
dynamicImportMode: 'eager', | ||
}, | ||
}, | ||
}, | ||
resolve: { | ||
extensionAlias: { | ||
'.js': ['.js', '.ts'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// TODO | ||
// import readline from 'readline'; | ||
// import { Message, VercelChatModelAdapter, createApp } from '@callstack/byorg-core'; | ||
// import { createOpenAI } from '@ai-sdk/openai'; | ||
// import { requireEnv } from '@callstack/byorg-utils'; | ||
// import { createDiscordApp } from '@callstack/byorg-discord'; | ||
|
||
// const LANGUAGE_MODEL = 'gpt-4o-2024-11-20'; | ||
// const API_KEY = requireEnv('OPENAI_API_KEY'); | ||
|
||
// const openAiProvider = createOpenAI({ | ||
// apiKey: API_KEY, | ||
// compatibility: 'strict', // strict mode, enable when using the OpenAI API | ||
// }); | ||
|
||
// const openAiModel = openAiProvider.languageModel(LANGUAGE_MODEL); | ||
|
||
// const chatModel = new VercelChatModelAdapter({ | ||
// languageModel: openAiModel, | ||
// }); | ||
|
||
// const systemPrompt = () => { | ||
// return 'Your name is Cassandra. You are an AI Assistant.'; | ||
// }; | ||
|
||
// const app = createApp({ | ||
// chatModel, | ||
// systemPrompt, | ||
// }); | ||
|
||
// // const discord = createDiscordApp({ | ||
// // app, | ||
// // }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"noEmit": false, | ||
"paths": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "node16", | ||
"moduleResolution": "node16", | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noStrictGenericChecks": false, | ||
"skipLibCheck": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "react" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules/ | ||
dist/ | ||
rslib.config.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"root": true, | ||
"extends": ["@callstack/eslint-config/node", "prettier"], | ||
"settings": { | ||
"import/resolver": { | ||
"typescript": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "slack-example", | ||
"version": "1.0.0", | ||
"description": "Example usage of byorg.ai slack integration", | ||
"type": "module", | ||
"main": "dist/index.js", | ||
"private": true, | ||
"bin": { | ||
"example": "./index.js" | ||
}, | ||
"scripts": { | ||
"build": "rsbuild build", | ||
"example": "pnpm build && dotenv -- node dist/index.cjs" | ||
}, | ||
"dependencies": { | ||
"@ai-sdk/openai": "^1.0.2", | ||
"@callstack/byorg-core": "0.4.2", | ||
"@callstack/byorg-slack": "0.4.2", | ||
"@callstack/byorg-utils": "0.4.2" | ||
}, | ||
"devDependencies": { | ||
"dotenv-cli": "^7.4.2", | ||
"@callstack/eslint-config": "^14.2.0", | ||
"@rsbuild/core": "^1.0.5", | ||
"eslint": "^8.57.0", | ||
"prettier": "^3.3.3", | ||
"typescript": "^5.6.3" | ||
}, | ||
"author": "", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { defineConfig } from '@rsbuild/core'; | ||
|
||
export default defineConfig({ | ||
source: { | ||
entry: { | ||
index: { | ||
filename: 'index.cjs', | ||
import: './src/index.ts', | ||
}, | ||
}, | ||
tsconfigPath: './tsconfig.build.json', | ||
}, | ||
output: { | ||
target: 'node', | ||
minify: false, | ||
}, | ||
tools: { | ||
rspack: { | ||
module: { | ||
parser: { | ||
javascript: { | ||
dynamicImportMode: 'eager', | ||
}, | ||
}, | ||
}, | ||
resolve: { | ||
extensionAlias: { | ||
'.js': ['.js', '.ts'], | ||
}, | ||
}, | ||
ignoreWarnings: [ | ||
/the request of a dependency is an expression/, | ||
/Can't resolve 'bufferutil'/, | ||
/Can't resolve 'utf-8-validate'/, | ||
], | ||
}, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { VercelChatModelAdapter, createApp } from '@callstack/byorg-core'; | ||
import { createOpenAI } from '@ai-sdk/openai'; | ||
import { logger, requireEnv } from '@callstack/byorg-utils'; | ||
import { createSlackApp } from '@callstack/byorg-slack'; | ||
|
||
const LANGUAGE_MODEL = 'gpt-4o-2024-11-20'; | ||
const API_KEY = requireEnv('OPENAI_API_KEY'); | ||
const SLACK_BOT_TOKEN = requireEnv('SLACK_BOT_TOKEN'); | ||
const SLACK_APP_TOKEN = requireEnv('SLACK_APP_TOKEN'); | ||
const SLACK_SIGNING_SECRET = requireEnv('SLACK_SIGNING_SECRET'); | ||
|
||
const openAiProvider = createOpenAI({ | ||
apiKey: API_KEY, | ||
compatibility: 'strict', // strict mode, enable when using the OpenAI API | ||
}); | ||
|
||
const chatModel = new VercelChatModelAdapter({ | ||
languageModel: openAiProvider.languageModel(LANGUAGE_MODEL), | ||
}); | ||
|
||
const SYSTEM_PROMPT = 'Your name is Byorg. You are an AI Assistant.'; | ||
|
||
const app = createApp({ | ||
chatModel, | ||
systemPrompt: () => SYSTEM_PROMPT, | ||
}); | ||
|
||
const slack = createSlackApp({ | ||
app, | ||
socketMode: true, | ||
token: SLACK_BOT_TOKEN, | ||
appToken: SLACK_APP_TOKEN, | ||
signingSecret: SLACK_SIGNING_SECRET, | ||
}); | ||
|
||
void (async () => { | ||
try { | ||
await slack.start(8080); | ||
logger.info('Slack ready.'); | ||
} catch (error) { | ||
logger.error('Dev Slack start error:', error); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"noEmit": false, | ||
"paths": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "node16", | ||
"moduleResolution": "node16", | ||
"noEmit": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"strict": true, | ||
"noStrictGenericChecks": false, | ||
"skipLibCheck": true, | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"jsx": "react" | ||
}, | ||
"include": ["src"] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
packages: | ||
- packages/* | ||
- docs | ||
- examples/* | ||
|
||
catalog: | ||
'@microsoft/api-extractor': '^7.47.12' | ||
|