Skip to content

Commit

Permalink
Merge pull request #102 from elsoul/backend
Browse files Browse the repository at this point in the history
update package version/update github actions
  • Loading branch information
POPPIN-FUMI authored Nov 14, 2023
2 parents 9a36090 + b0f0a02 commit 5cd244d
Show file tree
Hide file tree
Showing 10 changed files with 1,226 additions and 692 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/discord.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: SkeetFrameworkDiscord

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x]

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm i -g yarn
- run: yarn install
- name: Disord Notification Epics
run: yarn discord epics ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISCORD_TOKEN: ${{ secrets.DISCORD_TOKEN }}
DISCORD_CHANNEL_ID: ${{ secrets.DISCORD_CHANNEL_ID }}
DISCORD_CHANNEL_ID_JA: ${{ secrets.DISCORD_CHANNEL_ID_JA }}
- name: Disord Notification LABO
run: yarn discord labo ${{ github.repository }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISCORD_TOKEN_LABO: ${{ secrets.DISCORD_TOKEN_LABO }}
LABO_SKEET_CHANNEL_ID: ${{ secrets.LABO_SKEET_CHANNEL_ID }}
- name: Post X package update notification
if: success()
run: |
curl --location ${{ secrets.TW_ENDPOINT }} \
--header 'Content-Type: application/json' \
--data '{"repo": "${{ github.repository }}", "hey": "${{ secrets.TW_ENDPOINT_SECRET }}"}'
27 changes: 27 additions & 0 deletions .github/workflows/runDiscordChangeLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { discordChangeLog } from '@skeet-framework/discord-utils'
import { dotenv } from '@skeet-framework/utils'
dotenv.config()

type ProjectType = 'labo' | 'epics'

const run = async (project: ProjectType, repoName: string) => {
if (project === 'labo') {
console.log('labo')
const token = process.env.DISCORD_TOKEN_LABO || ''
const channelId = process.env.LABO_SKEET_CHANNEL_ID || ''
await discordChangeLog(token, repoName, [channelId])
} else if (project === 'epics') {
console.log('epics')
const token = process.env.DISCORD_TOKEN || ''
const channelId = process.env.DISCORD_CHANNEL_ID || ''
const channelIdJA = process.env.DISCORD_CHANNEL_ID_JA || ''
await discordChangeLog(token, repoName, [channelId])
await discordChangeLog(token, repoName, [channelIdJA], 'ja')
} else {
console.log('invalid project name')
}
}

const project = process.argv[2] as ProjectType
const repoArg = process.argv[3] || ''
void run(project, repoArg)
26 changes: 13 additions & 13 deletions functions/skeet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
},
"main": "dist/index.js",
"dependencies": {
"@skeet-framework/ai": "1.7.3",
"@skeet-framework/firestore": "2.3.2",
"@skeet-framework/utils": "1.2.1",
"firebase-admin": "11.10.1",
"firebase-functions": "4.4.1"
"@skeet-framework/ai": "1.7.8",
"@skeet-framework/firestore": "2.4.2",
"@skeet-framework/utils": "1.2.3",
"firebase-admin": "11.11.0",
"firebase-functions": "4.5.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "6.5.0",
"@typescript-eslint/parser": "6.5.0",
"esbuild": "0.19.2",
"eslint": "8.48.0",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/parser": "6.11.0",
"esbuild": "0.19.5",
"eslint": "8.53.0",
"eslint-config-google": "0.14.0",
"eslint-plugin-import": "2.28.1",
"firebase": "10.3.0",
"eslint-plugin-import": "2.29.0",
"firebase": "10.6.0",
"nodemon": "3.0.1",
"npm-check-updates": "16.13.2",
"prettier": "3.0.3",
"npm-check-updates": "16.14.6",
"prettier": "3.1.0",
"typescript": "5.2.2"
},
"private": true
Expand Down
14 changes: 14 additions & 0 deletions functions/skeet/src/lib/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { dotenv } from '@skeet-framework/utils'
dotenv.config()

const NODE_ENV = process.env.NODE_ENV || 'development'

// Define Constants in one place
// e.g. Discord Constants
export const DISCORD_APPLICATION_ID = ''
export const DISCORD_PUBKEY = ''
export const DISCORD_GUILD_ID = ''

export const config = {
NODE_ENV,
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const addStreamUserChatRoomMessage = onRequest(
body.userChatRoomId,
)

if (!userChatRoom) throw new Error('userChatRoom is not found')

// Add User Message to UserChatRoomMessage
const messagesPath = genUserChatRoomMessagePath(
user.uid,
Expand Down Expand Up @@ -108,7 +110,7 @@ export const addStreamUserChatRoomMessage = onRequest(
}

// Get OpenAI Stream
const stream = await openAi.promptStream(messages)
const stream = await openAi.promptStream(messages.messages)
const messageResults: any[] = []
for await (const part of stream) {
const message = String(part.choices[0].delta.content)
Expand Down
5 changes: 4 additions & 1 deletion functions/skeet/src/routings/http/addVertexMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {
genVertexChatRoomMessagePath,
} from '@/models'
import { getUserAuth } from '@/lib'
import { AddVertexMessageParams, TypedRequestBody } from '@/types/http'
import { TypedRequestBody } from '@/types/http'
import { onRequest } from 'firebase-functions/v2/https'
import { publicHttpOption } from '../options'
import { sendToVertexAI, streamResponse } from '@/lib'
import { add, get } from '@skeet-framework/firestore'
import { AddVertexMessageParams } from '@/types/http/addVertexMessageParams'

export const addVertexMessage = onRequest(
publicHttpOption,
Expand All @@ -26,6 +27,8 @@ export const addVertexMessage = onRequest(
chatRoomPath,
req.body.vertexChatRoomId,
)
if (!vertexChatRoomData) throw new Error('vertexChatRoom is not found')

const vertexExampleData = vertexChatRoomData.examples

// Send to VertexAI
Expand Down
5 changes: 0 additions & 5 deletions functions/skeet/src/types/http/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
export * from './addVertexMessageParams'
export * from './addStreamUserChatRoomMessageParams'
export * from './addUserChatRoomMessageParams'
export * from './createUserChatRoomParams'
export * from './addVertexMessageParams'
import { Request } from 'firebase-functions/v2/https'

export interface TypedRequestBody<T> extends Request {
Expand Down
Loading

0 comments on commit 5cd244d

Please sign in to comment.