Spaces:
Runtime error
Runtime error
fix: Import module errors
Browse files
app.py
CHANGED
@@ -7,15 +7,15 @@ from qdrant_client import QdrantClient
|
|
7 |
from fastembed import TextEmbedding
|
8 |
|
9 |
from llama_index.llms.openai import OpenAI
|
10 |
-
from
|
11 |
-
from
|
12 |
|
13 |
ocr = PaddleOCR(use_angle_cls=True, lang="en", use_gpu=False)
|
14 |
llm = OpenAI(model="gpt-3.5-turbo")
|
15 |
rec_engine = RecommendationEngine("food", QdrantClient(":memory"), TextEmbedding())
|
16 |
|
17 |
|
18 |
-
def run_ocr(img_path):
|
19 |
result = ocr.ocr(img_path, cls=True)[0]
|
20 |
return "\n".join([line[1][0] for line in result])
|
21 |
|
|
|
7 |
from fastembed import TextEmbedding
|
8 |
|
9 |
from llama_index.llms.openai import OpenAI
|
10 |
+
from .utils import extract_food_items, synthesize_food_item
|
11 |
+
from .main import RecommendationEngine
|
12 |
|
13 |
ocr = PaddleOCR(use_angle_cls=True, lang="en", use_gpu=False)
|
14 |
llm = OpenAI(model="gpt-3.5-turbo")
|
15 |
rec_engine = RecommendationEngine("food", QdrantClient(":memory"), TextEmbedding())
|
16 |
|
17 |
|
18 |
+
def run_ocr(img_path) -> str:
|
19 |
result = ocr.ocr(img_path, cls=True)[0]
|
20 |
return "\n".join([line[1][0] for line in result])
|
21 |
|
main.py
CHANGED
@@ -4,8 +4,8 @@ from qdrant_client import QdrantClient, models as qmodels
|
|
4 |
from llama_index.llms.openai import OpenAI
|
5 |
from fastembed import TextEmbedding
|
6 |
|
7 |
-
from
|
8 |
-
from
|
9 |
|
10 |
likes = ["dosa", "fanta", "croissant", "waffles"]
|
11 |
dislikes = ["virgin mojito"]
|
@@ -65,7 +65,7 @@ class RecommendationEngine:
|
|
65 |
|
66 |
def recommend_from_given(
|
67 |
self, items: List[FoodItem], limit: int = 3
|
68 |
-
) -> Dict[str,
|
69 |
liked_points, _offset = self.qdrant.scroll(
|
70 |
self.collection,
|
71 |
scroll_filter={"must": [{"key": "liked", "match": {"value": True}}]},
|
|
|
4 |
from llama_index.llms.openai import OpenAI
|
5 |
from fastembed import TextEmbedding
|
6 |
|
7 |
+
from .models import FoodItem
|
8 |
+
from .utils import synthesize_food_item
|
9 |
|
10 |
likes = ["dosa", "fanta", "croissant", "waffles"]
|
11 |
dislikes = ["virgin mojito"]
|
|
|
65 |
|
66 |
def recommend_from_given(
|
67 |
self, items: List[FoodItem], limit: int = 3
|
68 |
+
) -> Dict[str, float]:
|
69 |
liked_points, _offset = self.qdrant.scroll(
|
70 |
self.collection,
|
71 |
scroll_filter={"must": [{"key": "liked", "match": {"value": True}}]},
|
utils.py
CHANGED
@@ -2,7 +2,7 @@ from typing import List
|
|
2 |
from llama_index.program.openai import OpenAIPydanticProgram
|
3 |
from llama_index.core.llms.llm import LLM
|
4 |
|
5 |
-
from
|
6 |
|
7 |
|
8 |
def synthesize_food_item(food_name: str, llm: LLM) -> FoodItem:
|
|
|
2 |
from llama_index.program.openai import OpenAIPydanticProgram
|
3 |
from llama_index.core.llms.llm import LLM
|
4 |
|
5 |
+
from .models import FoodItem, ExtractedFoodName
|
6 |
|
7 |
|
8 |
def synthesize_food_item(food_name: str, llm: LLM) -> FoodItem:
|