Skip to content

Commit

Permalink
Merge branch 'develop' into future/efect
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuma-Satake authored Aug 28, 2023
2 parents 830ebee + e825aee commit 126fbe7
Show file tree
Hide file tree
Showing 42 changed files with 1,456 additions and 429 deletions.
4 changes: 3 additions & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
Expand All @@ -10,5 +11,6 @@ module.exports = {
plugins: ['react-refresh'],
rules: {
'react-refresh/only-export-components': 'warn',
'react-hooks/exhaustive-deps': 'off',
},
}
};
25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,38 @@ on:

jobs:
eslint:
name: Run eslint scanning
runs-on: ubuntu-latest
name: Run eslint scanning
runs-on: ubuntu-latest
steps:
- name: Checkout code #コードを持ってくる
- name: Checkout code #コードを持ってくる
uses: actions/checkout@v3

- name: Install ESLint #ESlintをインストールする
- name: Install ESLint #ESlintをインストールする
run: |
npm install [email protected]
npm install @microsoft/[email protected]
- name: Run ESLint #ESLintを実行する
run:
npx eslint . --ext .js,.jsx,.ts,.tsx --format @microsoft/eslint-formatter-sarif
- name: Run ESLint #ESLintを実行する
run: npx eslint ./src --ext .js,.jsx,.ts,.tsx --format @microsoft/eslint-formatter-sarif
--output-file eslint-results.sarif
continue-on-error: true

- name: Upload analysis results to GitHub #githubに解析結果をアップロード
- name: Upload analysis results to GitHub #githubに解析結果をアップロード
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: eslint-results.sarif
wait-for-processing: true

rome:
name: Run rome scanning
name: Run rome scanning
runs-on: ubuntu-latest
steps:
- name: Checkout code #コードを持ってくる
- name: Checkout code #コードを持ってくる
uses: actions/checkout@v3

- name: Install Rome #romeをインストールする
- name: Install Rome #romeをインストールする
run: |
npm install [email protected]
- name: Run Rome #romeを実行
run: npx rome check ./src
- name: Run Rome #romeを実行
run: npx rome check ./src
5 changes: 5 additions & 0 deletions doc/battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
バトルする
勝つ
ツイートできるようにする
負ける
励ましの言葉をヤギにかける
44 changes: 44 additions & 0 deletions functions/lib/index.js

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

2 changes: 1 addition & 1 deletion functions/lib/index.js.map

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

50 changes: 50 additions & 0 deletions functions/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,53 @@ ${reqText}というワードがどのような場面で利用されるかを"Joy
return;
}
});

exports.gptwrapper = onRequest({ cors: [/firebase\.com$/, 'flutter.com'] }, async (req, res) => {
/**
* 本番環境ではコメントアウトする
*/
res.setHeader('Access-Control-Allow-Origin', '*');

//reqText
const reqText = req.query.text;
if (!reqText) {
res.status(400).send('NoText');
return;
}

//context
const requestContext = reqText as string;

try {
//config
if (!apiKey) {
res.status(500).send('NoApiKey');
return;
}
const config = new Configuration({
apiKey: apiKey,
});

//params
const params: CreateChatCompletionRequest = {
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: requestContext }],
};

//OpenAI
const aiInstance = new OpenAIApi(config);
const openAiRes = await aiInstance.createChatCompletion(params);
const aiResText = openAiRes.data.choices[0].message?.content;

if (!aiResText) {
res.status(500).send('GPTError');
return;
}

res.status(200).send(openAiRes.data);
return;
} catch (e) {
res.status(500).send(e);
return;
}
});
170 changes: 152 additions & 18 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.6",
"@swc/core": "^1.3.76",
"axios": "^1.4.0",
"dayjs": "^1.11.8",
"firebase": "^9.23.0",
Expand Down
Loading

0 comments on commit 126fbe7

Please sign in to comment.