Skip to content

Commit b6f8f2b

Browse files
Merge pull request #5 from winc1980/develop
✨ Feat: レシピ詳細の実装完了
2 parents 5a0e6c4 + 9ec7ba5 commit b6f8f2b

File tree

9 files changed

+391
-285
lines changed

9 files changed

+391
-285
lines changed

README.md

+52-3
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,23 @@
44
<p align="center">HPチーム春合宿2024年 グループ3 作品</p>
55
</p>
66
<p align="center">
7-
<img src="https://img.shields.io/badge/3-Vue.js-4FC08D.svg?logo=vue.js&style=plastic">
8-
<img src="https://img.shields.io/badge/20-Node.js-339933.svg?logo=node.js&style=plastic">
7+
<img src="https://img.shields.io/badge/Vue.js-3-4FC08D.svg?logo=vue.js&style=plastic">
8+
<img src="https://img.shields.io/badge/Node.js-20-339933.svg?logo=node.js&style=plastic">
99
<img src="https://github.com/winc1980/recipe-ai/actions/workflows/deploy-gh-pages.yml/badge.svg">
1010
</p>
1111

1212
## アプリの特徴
1313

14-
- **冷蔵庫内の写真から食材を検出する**
14+
- **冷蔵庫内の写真から食材を選ぶ**
15+
- GPTの強力な推論能力を用いて冷蔵庫内の写真から食材を検出します。
1516
- **レシピの提案**
1617
- 最適なレシピを提案します。その他にも「料理時間」や「難易度」、「カロリー」などの情報もすぐに確認できます。
1718
- **レシピの詳細**
19+
- レシピの作り方を確認できます。
20+
21+
## アプリを使う
22+
23+
- [RECIPE AI](https://github.com/winc1980/recipe-ai) ここからアクセスしてください。
1824

1925
## スクリーンショット
2026

@@ -41,3 +47,46 @@ npm install
4147
```bash
4248
npm run dev
4349
```
50+
51+
## ビルド
52+
53+
```bash
54+
npm run build
55+
```
56+
57+
## Contributors✨
58+
59+
<table>
60+
<tbody>
61+
<tr>
62+
<td align="center" valign="top" width="14.28%">
63+
<a href="https://github.com/MORIMOTO520212">
64+
<img src="https://avatars.githubusercontent.com/u/28892090?v=4" /><br />
65+
<sub><b>Yuma Morimoto</b></sub></a><br />
66+
Backend
67+
</a>
68+
</td>
69+
<td align="center" valign="top" width="14.28%">
70+
<a href="https://github.com/shuma1356">
71+
<img src="https://avatars.githubusercontent.com/u/118163728?v=4" /><br />
72+
<sub><b>Shuma Miyazaki</b></sub></a><br />
73+
Design / Frontend
74+
</a>
75+
</td>
76+
<td align="center" valign="top" width="14.28%">
77+
<a href="https://github.com/momoka39">
78+
<img src="https://avatars.githubusercontent.com/u/133108363?v=4" /><br />
79+
<sub><b>Momoka</b></sub></a><br />
80+
Frontend
81+
</a>
82+
</td>
83+
<td align="center" valign="top" width="14.28%">
84+
<a href="">
85+
<img src="https://avatars.githubusercontent.com/u/88756450?v=4" /><br />
86+
<sub><b>Yuria</b></sub></a><br />
87+
Prompt Engineering / Frontend
88+
</a>
89+
</td>
90+
</tr>
91+
</tbody>
92+
</table>

src/App.vue

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,4 @@
1-
<script setup>
2-
import { ref } from 'vue';
3-
import { detectFoods } from './features/detectFoods';
4-
import { getImage } from './features/getImage';
5-
6-
const searchQuery = ref(''); // 検索キーワード変数
7-
const thumbnailUrl = ref(''); // サムネイルURL変数
8-
9-
// サムネイルURLを取得する
10-
const getThumbnailUrl = async () => {
11-
let url = await getImage(searchQuery.value);
12-
console.log(url);
13-
thumbnailUrl.value = url;
14-
};
15-
</script>
1+
<script setup></script>
162

173
<template>
184
<router-view />

src/components/HelloWorld.vue

-40
This file was deleted.

src/features/detectFoods/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ export const detectFoods = async (b64Image) => {
6565
},
6666
},
6767
],
68-
function_call: 'auto',
68+
function_call: {
69+
name: 'foods',
70+
},
6971
max_tokens: 1000,
7072
});
7173
return JSON.parse(chatCompletion2.choices[0].message.function_call.arguments);
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { openai } from '../openaiClient';
2+
3+
// レシピを生成する
4+
export const generateRecipeDetail = async (recipeName) => {
5+
console.log('レシピの詳細を生成中...');
6+
const chatCompletion = await openai.chat.completions.create({
7+
model: 'gpt-4-0613',
8+
messages: [
9+
{
10+
role: 'user',
11+
content: [
12+
{
13+
type: 'text',
14+
text: `${recipeName}\nこのレシピに必要な1人前の材料を考えてください。また、ステップバイステップでこのレシピを作るための手順を考えてください。最後に、recipe関数を呼び出して終了します。`,
15+
},
16+
],
17+
},
18+
],
19+
functions: [
20+
{
21+
name: 'recipe',
22+
parameters: {
23+
type: 'object',
24+
properties: {
25+
ingredients: {
26+
type: 'array',
27+
description:
28+
'このプロパティにはレシピに必要な材料のリストを渡します。',
29+
items: {
30+
type: 'string',
31+
},
32+
},
33+
amount: {
34+
type: 'array',
35+
description:
36+
'このプロパティには材料の使用量をリストで渡します。例えば、1-2個、小さじ1/2、3本など。',
37+
items: {
38+
type: 'string',
39+
},
40+
},
41+
cooking_instructions: {
42+
type: 'array',
43+
description:
44+
'このプロパティにはレシピを作るための手順をリストで渡します。手順の順番はリストの手前から始まることに注意してください。',
45+
items: {
46+
type: 'string',
47+
},
48+
},
49+
},
50+
required: ['ingredients', 'amount', 'cooking_instructions'],
51+
},
52+
},
53+
],
54+
function_call: {
55+
name: 'recipe',
56+
},
57+
max_tokens: 1000,
58+
});
59+
return JSON.parse(chatCompletion.choices[0].message.function_call.arguments);
60+
};

src/main.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import App from './App.vue';
88
const store = createStore({
99
state() {
1010
return {
11-
// 食材リスト(JPとEN)
11+
// 食材リスト
1212
foods: {
1313
// jp: ['ex_りんご', 'ex_きゅうり'],
1414
// en: ['apple', 'cucumber'],
@@ -18,10 +18,23 @@ const store = createStore({
1818
// ],
1919
jp: [],
2020
en: [],
21-
thumbnail: [],
21+
thumbnail: [
22+
'https://www.nikon-image.com/products/mirrorless/lineup/z_50/img/sample/pic_01_l.jpg',
23+
],
2224
},
2325
// 選択した食材(食材の名前)
2426
selectedFoods: [],
27+
// 生成したレシピ
28+
// {
29+
// title_jp: [],
30+
// title_en: [],
31+
// time: [],
32+
// kcal: [],
33+
// difficulty: [],
34+
// catchcopy: [],
35+
// thumbnail: [],
36+
// }
37+
generatedRecipe: {},
2538
};
2639
},
2740
mutations: {
@@ -39,6 +52,11 @@ const store = createStore({
3952
console.log('unSelectFood...');
4053
state.selectedFoods = state.selectedFoods.filter((n) => n !== name);
4154
},
55+
generatedRecipe(state, data) {
56+
console.log('generatedRecipe...');
57+
state.generatedRecipe = data;
58+
console.log(state.generatedRecipe);
59+
},
4260
},
4361
});
4462

0 commit comments

Comments
 (0)