1
1
from __future__ import annotations
2
2
3
3
from pgvector .sqlalchemy import Vector
4
- from sqlalchemy import VARCHAR , Index
5
- from sqlalchemy .dialects import postgresql
4
+ from sqlalchemy import Index
6
5
from sqlalchemy .orm import DeclarativeBase , Mapped , mapped_column
7
6
8
7
@@ -13,19 +12,14 @@ class Base(DeclarativeBase):
13
12
14
13
class Item (Base ):
15
14
__tablename__ = "items"
16
- id : Mapped [int ] = mapped_column (primary_key = True , autoincrement = True )
15
+ id : Mapped [str ] = mapped_column (primary_key = True )
17
16
name : Mapped [str ] = mapped_column ()
18
- location : Mapped [str ] = mapped_column ()
19
17
cuisine : Mapped [str ] = mapped_column ()
20
18
rating : Mapped [int ] = mapped_column ()
21
19
price_level : Mapped [int ] = mapped_column ()
22
20
review_count : Mapped [int ] = mapped_column ()
23
- hours : Mapped [str ] = mapped_column ()
24
- tags : Mapped [list [str ]] = mapped_column (postgresql .ARRAY (VARCHAR )) # Array of strings
25
21
description : Mapped [str ] = mapped_column ()
26
22
menu_summary : Mapped [str ] = mapped_column ()
27
- top_reviews : Mapped [str ] = mapped_column ()
28
- vibe : Mapped [str ] = mapped_column ()
29
23
30
24
# Embeddings for different models:
31
25
embedding_3l : Mapped [Vector ] = mapped_column (Vector (1024 ), nullable = True ) # text-embedding-3-large
@@ -42,10 +36,10 @@ def to_dict(self, include_embedding: bool = False):
42
36
return model_dict
43
37
44
38
def to_str_for_rag (self ):
45
- return f"Name:{ self .name } Description:{ self .description } Location: { self . location } Cuisine:{ self .cuisine } Rating:{ self .rating } Price Level:{ self .price_level } Review Count:{ self .review_count } Hours: { self . hours } Tags: { self . tags } Menu Summary:{ self .menu_summary } Top Reviews: { self . top_reviews } Vibe: { self . vibe } " # noqa: E501
39
+ return f"Name:{ self .name } Description:{ self .description } Cuisine:{ self .cuisine } Rating:{ self .rating } Price Level:{ self .price_level } Review Count:{ self .review_count } Menu Summary:{ self .menu_summary } " # noqa: E501
46
40
47
41
def to_str_for_embedding (self ):
48
- return f"Name: { self .name } Description: { self .description } Cuisine: { self .cuisine } Tags: { self . tags } Menu Summary: { self .menu_summary } Top Reviews: { self . top_reviews } Vibe: { self . vibe } " # noqa: E501
42
+ return f"Name: { self .name } Description: { self .description } Cuisine: { self .cuisine } Menu Summary: { self .menu_summary } " # noqa: E501
49
43
50
44
51
45
"""
0 commit comments