Samilincoln
commited on
Commit
·
581d6d0
1
Parent(s):
a66feca
adjusted files path
Browse files- app.py +12 -7
- docs/{Nigerian Foods.csv → Nigerian_Foods.csv} +0 -0
- requirements.txt +4 -0
app.py
CHANGED
|
@@ -4,27 +4,31 @@ import google.generativeai as genai
|
|
| 4 |
import gradio as gr
|
| 5 |
from google.api_core import retry
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
MODEL_NAME = 'gemini-1.5-flash-latest'
|
|
|
|
| 10 |
|
| 11 |
model = genai.GenerativeModel(
|
| 12 |
MODEL_NAME,
|
| 13 |
generation_config= genai.GenerationConfig(
|
| 14 |
-
temperature= 0
|
| 15 |
-
|
| 16 |
max_output_tokens=1000,
|
| 17 |
)
|
| 18 |
)
|
| 19 |
|
| 20 |
-
retry_policy = {"retry": retry.Retry(predicate=retry.if_transient_error, initial=10, multiplier= 1.5, timeout=300)}
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
-
food_data = pd.read_csv("Kitcher/docs/Nigerian Foods.csv")
|
| 24 |
-
json_file = "Kitcher/docs/food_data.json"
|
| 25 |
json_data = food_data.to_json(orient="records", lines=False, indent=4)
|
| 26 |
|
| 27 |
-
few_shot_prompt = f"
|
| 28 |
|
| 29 |
def recipe_chatbot(messages, history):
|
| 30 |
response = model.generate_content([few_shot_prompt,messages], request_options=retry_policy)
|
|
@@ -35,3 +39,4 @@ bot = gr.ChatInterface(
|
|
| 35 |
type="messages"
|
| 36 |
)
|
| 37 |
|
|
|
|
|
|
| 4 |
import gradio as gr
|
| 5 |
from google.api_core import retry
|
| 6 |
|
| 7 |
+
my_api_key = os.environ.get("GOOGLE-API-KEY")
|
| 8 |
+
|
| 9 |
+
genai.configure(api_key=my_api_key)
|
| 10 |
|
| 11 |
MODEL_NAME = 'gemini-1.5-flash-latest'
|
| 12 |
+
retry_policy = {"retry": retry.Retry(predicate=retry.if_transient_error, initial=10, multiplier= 1.5, timeout=300)}
|
| 13 |
|
| 14 |
model = genai.GenerativeModel(
|
| 15 |
MODEL_NAME,
|
| 16 |
generation_config= genai.GenerationConfig(
|
| 17 |
+
temperature= 1.0,
|
| 18 |
+
top_p= 1,
|
| 19 |
max_output_tokens=1000,
|
| 20 |
)
|
| 21 |
)
|
| 22 |
|
|
|
|
| 23 |
|
| 24 |
+
data_path = os.path.join("docs", "Nigerian_Foods.csv")
|
| 25 |
+
json_path = os.path.join("docs", "food_data.csv")
|
| 26 |
+
|
| 27 |
+
food_data = pd.read_csv(data_path)
|
| 28 |
|
|
|
|
|
|
|
| 29 |
json_data = food_data.to_json(orient="records", lines=False, indent=4)
|
| 30 |
|
| 31 |
+
few_shot_prompt = f" You are an interactive recipe assistant, using data form this file {json_data} for recipe recommendations ,And If recipe is not available, Give first most similar"
|
| 32 |
|
| 33 |
def recipe_chatbot(messages, history):
|
| 34 |
response = model.generate_content([few_shot_prompt,messages], request_options=retry_policy)
|
|
|
|
| 39 |
type="messages"
|
| 40 |
)
|
| 41 |
|
| 42 |
+
bot.launch()
|
docs/{Nigerian Foods.csv → Nigerian_Foods.csv}
RENAMED
|
File without changes
|
requirements.txt
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas>=1.3.0
|
| 2 |
+
gradio>=3.30.0
|
| 3 |
+
google-generativeai>=0.1.0
|
| 4 |
+
google-api-core>=2.0.0
|