Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -12,6 +12,7 @@ client = Groq(
|
|
| 12 |
|
| 13 |
# loading data
|
| 14 |
json_path = "format_food.json"
|
|
|
|
| 15 |
|
| 16 |
def metadata_func(record: dict, metadata: dict) -> dict:
|
| 17 |
metadata["title"] = record.get("title")
|
|
@@ -68,7 +69,7 @@ def run_query(query):
|
|
| 68 |
answer = qdrant.similarity_search(query=query, k=10)
|
| 69 |
title_and_description = f"# Best Choice:\nA {answer[0].metadata['title']}: {answer[0].page_content}"
|
| 70 |
instructions = format_to_markdown(answer[0].metadata['instructions'])
|
| 71 |
-
recipe = f"# Cooking time:\n{answer[0].metadata['time']}\n\n
|
| 72 |
print("Returning query")
|
| 73 |
chat_completion = client.chat.completions.create(
|
| 74 |
messages=[
|
|
@@ -79,7 +80,8 @@ def run_query(query):
|
|
| 79 |
],
|
| 80 |
model="Llama3-70b-8192",
|
| 81 |
)
|
| 82 |
-
|
|
|
|
| 83 |
|
| 84 |
with gr.Blocks() as demo:
|
| 85 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
|
@@ -90,4 +92,4 @@ with gr.Blocks() as demo:
|
|
| 90 |
btn = gr.Button("Run")
|
| 91 |
btn.click(fn=run_query, inputs=inp, outputs=[title_output, instructions_output, updated_recipe])
|
| 92 |
|
| 93 |
-
demo.launch()
|
|
|
|
| 12 |
|
| 13 |
# loading data
|
| 14 |
json_path = "format_food.json"
|
| 15 |
+
json_path = "llama70b_food_dump.json"
|
| 16 |
|
| 17 |
def metadata_func(record: dict, metadata: dict) -> dict:
|
| 18 |
metadata["title"] = record.get("title")
|
|
|
|
| 69 |
answer = qdrant.similarity_search(query=query, k=10)
|
| 70 |
title_and_description = f"# Best Choice:\nA {answer[0].metadata['title']}: {answer[0].page_content}"
|
| 71 |
instructions = format_to_markdown(answer[0].metadata['instructions'])
|
| 72 |
+
recipe = f"# Standard Method\n## Cooking time:\n{answer[0].metadata['time']}\n\n## Recipe:\n{instructions}"
|
| 73 |
print("Returning query")
|
| 74 |
chat_completion = client.chat.completions.create(
|
| 75 |
messages=[
|
|
|
|
| 80 |
],
|
| 81 |
model="Llama3-70b-8192",
|
| 82 |
)
|
| 83 |
+
groq_update = "# Groq Update\n"+chat_completion.choices[0].message.content
|
| 84 |
+
return title_and_description, recipe, groq_update
|
| 85 |
|
| 86 |
with gr.Blocks() as demo:
|
| 87 |
gr.Markdown("Start typing below and then click **Run** to see the output.")
|
|
|
|
| 92 |
btn = gr.Button("Run")
|
| 93 |
btn.click(fn=run_query, inputs=inp, outputs=[title_output, instructions_output, updated_recipe])
|
| 94 |
|
| 95 |
+
demo.launch()
|