Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,14 @@
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
-
|
4 |
# Set up OpenAI API credentials
|
5 |
openai.api_key = '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'
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
def get_food_recommendation(prompt):
|
8 |
# Generate a response using the ChatGPT API
|
9 |
response = openai.Completion.create(
|
@@ -20,8 +25,17 @@ def get_food_recommendation(prompt):
|
|
20 |
|
21 |
return recommendation
|
22 |
|
23 |
-
|
24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
st.title("Food and Nutrition Recommendation System")
|
26 |
st.write("Welcome to Food and Nutrition Recommendation System")
|
27 |
st.markdown('''The following are some examples that the webpage can help with :
|
@@ -30,17 +44,37 @@ def main():
|
|
30 |
- recipe for beef fried rice
|
31 |
- rice shrimp spices recipe
|
32 |
- foods for diabetes Korean''')
|
33 |
-
prompt = st.text_area("Enter your request for food recommendation")
|
34 |
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
if prompt:
|
37 |
recommendation_prompt = f"I'm looking for a food recommendation with the complete ingredients list based on the following criteria: {prompt}"
|
38 |
recommendation = get_food_recommendation(recommendation_prompt)
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
else:
|
41 |
st.warning("Please enter your request.")
|
42 |
|
43 |
if __name__ == "__main__":
|
44 |
main()
|
45 |
-
|
46 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import openai
|
3 |
+
from googletrans import Translator
|
4 |
# Set up OpenAI API credentials
|
5 |
openai.api_key = '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'
|
6 |
|
7 |
+
def translate_text(text, target_language):
|
8 |
+
translator = Translator()
|
9 |
+
translation = translator.translate(text, dest=target_language)
|
10 |
+
return translation.text
|
11 |
+
|
12 |
def get_food_recommendation(prompt):
|
13 |
# Generate a response using the ChatGPT API
|
14 |
response = openai.Completion.create(
|
|
|
25 |
|
26 |
return recommendation
|
27 |
|
28 |
+
def korean_text():
|
29 |
+
st.title("μν λ° μμ κΆμ₯ μμ€ν
")
|
30 |
+
st.write("μν λ° μμ κΆμ₯ μμ€ν
μ μ€μ κ²μ νμν©λλ€")
|
31 |
+
st.markdown("μΉνμ΄μ§μμ λμμ΄ λ μ μλ λͺ κ°μ§ μμμ
λλ€:")
|
32 |
+
st.markdown("- 200μΉΌλ‘리 μμ νκ΅μ΄")
|
33 |
+
st.markdown("- μκ³ κΈ° λ³Άμλ°₯ λ μνΌ")
|
34 |
+
st.markdown("- μ μμ° μ€νμ΄μ€ λ μνΌ")
|
35 |
+
st.markdown("- λΉλ¨λ³μ μ’μ μμ νκ΅μ΄")
|
36 |
+
|
37 |
+
|
38 |
+
def eng_func():
|
39 |
st.title("Food and Nutrition Recommendation System")
|
40 |
st.write("Welcome to Food and Nutrition Recommendation System")
|
41 |
st.markdown('''The following are some examples that the webpage can help with :
|
|
|
44 |
- recipe for beef fried rice
|
45 |
- rice shrimp spices recipe
|
46 |
- foods for diabetes Korean''')
|
|
|
47 |
|
48 |
+
# Streamlit app
|
49 |
+
def main():
|
50 |
+
target_language = "ko" # Set the target language to Korean
|
51 |
+
|
52 |
+
col1, col2 = st.columns(2)
|
53 |
+
|
54 |
+
with col1:
|
55 |
+
eng_func()
|
56 |
+
|
57 |
+
with col2:
|
58 |
+
korean_text()
|
59 |
+
|
60 |
+
prompt = st.text_area("Enter your request for food recommendation/ μμ μΆμ² μμ²μ μ
λ ₯νμΈμ ")
|
61 |
+
|
62 |
+
if st.button("Get Recommendation/μΆμ² λ°κΈ°"):
|
63 |
if prompt:
|
64 |
recommendation_prompt = f"I'm looking for a food recommendation with the complete ingredients list based on the following criteria: {prompt}"
|
65 |
recommendation = get_food_recommendation(recommendation_prompt)
|
66 |
+
translated_recommendation = translate_text(recommendation, target_language)
|
67 |
+
|
68 |
+
st.markdown("Recommendation (English / Korean):")
|
69 |
+
col3, col4 = st.columns(2)
|
70 |
+
|
71 |
+
with col3:
|
72 |
+
st.write(recommendation)
|
73 |
+
|
74 |
+
with col4:
|
75 |
+
st.write(translated_recommendation)
|
76 |
else:
|
77 |
st.warning("Please enter your request.")
|
78 |
|
79 |
if __name__ == "__main__":
|
80 |
main()
|
|
|
|