Spaces:
Sleeping
Sleeping
Commit
·
76d5a8f
1
Parent(s):
a1d6bb6
add yandex gpt
Browse files- app.py +22 -4
- requirements.txt +1 -1
app.py
CHANGED
@@ -27,12 +27,30 @@ def get_ingridients(image):
|
|
27 |
return ', '.join(ingridients)
|
28 |
|
29 |
|
30 |
-
|
|
|
31 |
|
32 |
def get_reciepe(ingridients):
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
|
37 |
def get_answer(image):
|
38 |
ingridients = get_ingridients(image)
|
|
|
27 |
return ', '.join(ingridients)
|
28 |
|
29 |
|
30 |
+
from yandex_cloud_ml_sdk import YCloudML
|
31 |
+
import os
|
32 |
|
33 |
def get_reciepe(ingridients):
|
34 |
+
messages = [
|
35 |
+
{
|
36 |
+
"role": "system",
|
37 |
+
"text": "suggest a dish that can be prepared from the suggested ingredients",
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"role": "user",
|
41 |
+
"text": "spaghetti squash, Granny Smith, cucumber, cuke",
|
42 |
+
},
|
43 |
+
]
|
44 |
+
|
45 |
+
sdk = YCloudML(
|
46 |
+
folder_id="b1ghdrfjtfkvir55hc0m",
|
47 |
+
auth=os.getenv('YC_APIKEY'),
|
48 |
+
)
|
49 |
+
|
50 |
+
result = (
|
51 |
+
sdk.models.completions("yandexgpt-lite").configure(temperature=0.5).run(messages)
|
52 |
+
)
|
53 |
+
return str(result[0].text)
|
54 |
|
55 |
def get_answer(image):
|
56 |
ingridients = get_ingridients(image)
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
transformers
|
2 |
torch
|
3 |
Pillow
|
4 |
-
|
|
|
1 |
transformers
|
2 |
torch
|
3 |
Pillow
|
4 |
+
yandex-cloud-ml-sdk
|