MongoDB Atlas + Fireworks AI RAG 示例¶
In [ ]
已复制!
!pip install -q llama-index llama-index-vector-stores-mongodb llama-index-embeddings-fireworks==0.1.2 llama-index-llms-fireworks
!pip install -q pymongo datasets pandas
!pip install -q llama-index llama-index-vector-stores-mongodb llama-index-embeddings-fireworks==0.1.2 llama-index-llms-fireworks !pip install -q pymongo datasets pandas
In [ ]
已复制!
# set up Fireworks.ai Key
import os
import getpass
fw_api_key = getpass.getpass("Fireworks API Key:")
os.environ["FIREWORKS_API_KEY"] = fw_api_key
# set up Fireworks.ai Key import os import getpass fw_api_key = getpass.getpass("Fireworks API Key:") os.environ["FIREWORKS_API_KEY"] = fw_api_key
In [ ]
已复制!
from datasets import load_dataset
import pandas as pd
# https://hugging-face.cn/datasets/AIatMongoDB/whatscooking.restaurants
dataset = load_dataset("AIatMongoDB/whatscooking.restaurants")
# Convert the dataset to a pandas dataframe
dataset_df = pd.DataFrame(dataset["train"])
dataset_df.head(5)
from datasets import load_dataset import pandas as pd # https://hugging-face.cn/datasets/AIatMongoDB/whatscooking.restaurants dataset = load_dataset("AIatMongoDB/whatscooking.restaurants") # Convert the dataset to a pandas dataframe dataset_df = pd.DataFrame(dataset["train"]) dataset_df.head(5)
/mnt/disks/data/llama_index/.venv/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .autonotebook import tqdm as notebook_tqdm
Out[ ]
restaurant_id | attributes | cuisine | DogsAllowed | embedding | OutdoorSeating | borough | address | _id | name | menu | TakeOut | location | PriceRange | HappyHour | review_count | sponsored | stars | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 40366661 | {'Alcohol': ''none'', 'Ambience': '{'romantic'... | Tex-Mex | 无 | [-0.14520384, 0.018315623, -0.018330636, -0.10... | True | Manhattan | {'building': '627', 'coord': [-73.975980999999... | {'$oid': '6095a34a7c34416a90d3206b'} | Baby Bo'S Burritos | 无 | True | {'coordinates': [-73.97598099999999, 40.745132... | 1.0 | 无 | 10 | NaN | 2.5 |
1 | 40367442 | {'Alcohol': ''beer_and_wine'', 'Ambience': '{'... | American | True | [-0.11977468, -0.02157107, 0.0038846824, -0.09... | True | Staten Island | {'building': '17', 'coord': [-74.1350211, 40.6... | {'$oid': '6095a34a7c34416a90d3209e'} | Buddy'S Wonder Bar | [Grilled cheese sandwich, Baked potato, Lasagn... | True | {'coordinates': [-74.1350211, 40.6369042], 'ty... | 2.0 | 无 | 62 | NaN | 3.5 |
2 | 40364610 | {'Alcohol': ''none'', 'Ambience': '{'touristy'... | American | 无 | [-0.1004329, -0.014882699, -0.033005167, -0.09... | True | Staten Island | {'building': '37', 'coord': [-74.138263, 40.54... | {'$oid': '6095a34a7c34416a90d31ff6'} | Great Kills Yacht Club | [Mozzarella sticks, Mushroom swiss burger, Spi... | True | {'coordinates': [-74.138263, 40.546681], 'type... | 1.0 | 无 | 72 | NaN | 4.0 |
3 | 40365288 | {'Alcohol': None, 'Ambience': '{'touristy': Fa... | American | 无 | [-0.11735515, -0.0397448, -0.0072645755, -0.09... | True | Manhattan | {'building': '842', 'coord': [-73.970637000000... | {'$oid': '6095a34a7c34416a90d32017'} | Keats Restaurant | [French fries, Chicken pot pie, Mac & cheese, ... | True | {'coordinates': [-73.97063700000001, 40.751495... | 2.0 | True | 149 | NaN | 4.0 |
4 | 40363151 | {'Alcohol': None, 'Ambience': None, 'BYOB': No... | Bakery | 无 | [-0.096541286, -0.009661355, 0.04402167, -0.12... | True | Manhattan | {'building': '120', 'coord': [-73.9998042, 40.... | {'$oid': '6095a34a7c34416a90d31fbd'} | Olive'S | [doughnuts, chocolate chip cookies, chocolate ... | True | {'coordinates': [-73.9998042, 40.7251256], 'ty... | 1.0 | 无 | 7 | NaN | 5.0 |
In [ ]
已复制!
from llama_index.core.settings import Settings
from llama_index.llms.fireworks import Fireworks
from llama_index.embeddings.fireworks import FireworksEmbedding
embed_model = FireworksEmbedding(
embed_batch_size=512,
model_name="nomic-ai/nomic-embed-text-v1.5",
api_key=fw_api_key,
)
llm = Fireworks(
temperature=0,
model="accounts/fireworks/models/mixtral-8x7b-instruct",
api_key=fw_api_key,
)
Settings.llm = llm
Settings.embed_model = embed_model
from llama_index.core.settings import Settings from llama_index.llms.fireworks import Fireworks from llama_index.embeddings.fireworks import FireworksEmbedding embed_model = FireworksEmbedding( embed_batch_size=512, model_name="nomic-ai/nomic-embed-text-v1.5", api_key=fw_api_key, ) llm = Fireworks( temperature=0, model="accounts/fireworks/models/mixtral-8x7b-instruct", api_key=fw_api_key, ) Settings.llm = llm Settings.embed_model = embed_model
In [ ]
已复制!
import json
from llama_index.core import Document
from llama_index.core.schema import MetadataMode
# Convert the DataFrame to a JSON string representation
documents_json = dataset_df.to_json(orient="records")
# Load the JSON string into a Python list of dictionaries
documents_list = json.loads(documents_json)
llama_documents = []
for document in documents_list:
# Value for metadata must be one of (str, int, float, None)
document["name"] = json.dumps(document["name"])
document["cuisine"] = json.dumps(document["cuisine"])
document["attributes"] = json.dumps(document["attributes"])
document["menu"] = json.dumps(document["menu"])
document["borough"] = json.dumps(document["borough"])
document["address"] = json.dumps(document["address"])
document["PriceRange"] = json.dumps(document["PriceRange"])
document["HappyHour"] = json.dumps(document["HappyHour"])
document["review_count"] = json.dumps(document["review_count"])
document["TakeOut"] = json.dumps(document["TakeOut"])
# these two fields are not relevant to the question we want to answer,
# so I will skip it for now
del document["embedding"]
del document["location"]
# Create a Document object with the text and excluded metadata for llm and embedding models
llama_document = Document(
text=json.dumps(document),
metadata=document,
metadata_template="{key}=>{value}",
text_template="Metadata: {metadata_str}\n-----\nContent: {content}",
)
llama_documents.append(llama_document)
# Observing an example of what the LLM and Embedding model receive as input
print(
"\nThe LLM sees this: \n",
llama_documents[0].get_content(metadata_mode=MetadataMode.LLM),
)
print(
"\nThe Embedding model sees this: \n",
llama_documents[0].get_content(metadata_mode=MetadataMode.EMBED),
)
import json from llama_index.core import Document from llama_index.core.schema import MetadataMode # Convert the DataFrame to a JSON string representation documents_json = dataset_df.to_json(orient="records") # Load the JSON string into a Python list of dictionaries documents_list = json.loads(documents_json) llama_documents = [] for document in documents_list: # Value for metadata must be one of (str, int, float, None) document["name"] = json.dumps(document["name"]) document["cuisine"] = json.dumps(document["cuisine"]) document["attributes"] = json.dumps(document["attributes"]) document["menu"] = json.dumps(document["menu"]) document["borough"] = json.dumps(document["borough"]) document["address"] = json.dumps(document["address"]) document["PriceRange"] = json.dumps(document["PriceRange"]) document["HappyHour"] = json.dumps(document["HappyHour"]) document["review_count"] = json.dumps(document["review_count"]) document["TakeOut"] = json.dumps(document["TakeOut"]) # these two fields are not relevant to the question we want to answer, # so I will skip it for now del document["embedding"] del document["location"] # Create a Document object with the text and excluded metadata for llm and embedding models llama_document = Document( text=json.dumps(document), metadata=document, metadata_template="{key}=>{value}", text_template="Metadata: {metadata_str}\n-----\nContent: {content}", ) llama_documents.append(llama_document) # Observing an example of what the LLM and Embedding model receive as input print( "\nThe LLM sees this: \n", llama_documents[0].get_content(metadata_mode=MetadataMode.LLM), ) print( "\nThe Embedding model sees this: \n", llama_documents[0].get_content(metadata_mode=MetadataMode.EMBED), )
The LLM sees this: Metadata: restaurant_id=>40366661 attributes=>{"Alcohol": "'none'", "Ambience": "{'romantic': False, 'intimate': False, 'classy': False, 'hipster': False, 'divey': False, 'touristy': False, 'trendy': False, 'upscale': False, 'casual': False}", "BYOB": null, "BestNights": null, "BikeParking": null, "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": null, "BusinessParking": "None", "Caters": "True", "DriveThru": null, "GoodForDancing": null, "GoodForKids": "True", "GoodForMeal": null, "HasTV": "True", "Music": null, "NoiseLevel": "'average'", "RestaurantsAttire": "'casual'", "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "True", "RestaurantsTableService": "False", "WheelchairAccessible": "True", "WiFi": "'free'"} cuisine=>"Tex-Mex" DogsAllowed=>None OutdoorSeating=>True borough=>"Manhattan" address=>{"building": "627", "coord": [-73.975981, 40.745132], "street": "2 Avenue", "zipcode": "10016"} _id=>{'$oid': '6095a34a7c34416a90d3206b'} name=>"Baby Bo'S Burritos" menu=>null TakeOut=>true PriceRange=>1.0 HappyHour=>null review_count=>10 sponsored=>None stars=>2.5 ----- Content: {"restaurant_id": "40366661", "attributes": "{\"Alcohol\": \"'none'\", \"Ambience\": \"{'romantic': False, 'intimate': False, 'classy': False, 'hipster': False, 'divey': False, 'touristy': False, 'trendy': False, 'upscale': False, 'casual': False}\", \"BYOB\": null, \"BestNights\": null, \"BikeParking\": null, \"BusinessAcceptsBitcoin\": null, \"BusinessAcceptsCreditCards\": null, \"BusinessParking\": \"None\", \"Caters\": \"True\", \"DriveThru\": null, \"GoodForDancing\": null, \"GoodForKids\": \"True\", \"GoodForMeal\": null, \"HasTV\": \"True\", \"Music\": null, \"NoiseLevel\": \"'average'\", \"RestaurantsAttire\": \"'casual'\", \"RestaurantsDelivery\": \"True\", \"RestaurantsGoodForGroups\": \"True\", \"RestaurantsReservations\": \"True\", \"RestaurantsTableService\": \"False\", \"WheelchairAccessible\": \"True\", \"WiFi\": \"'free'\"}", "cuisine": "\"Tex-Mex\"", "DogsAllowed": null, "OutdoorSeating": true, "borough": "\"Manhattan\"", "address": "{\"building\": \"627\", \"coord\": [-73.975981, 40.745132], \"street\": \"2 Avenue\", \"zipcode\": \"10016\"}", "_id": {"$oid": "6095a34a7c34416a90d3206b"}, "name": "\"Baby Bo'S Burritos\"", "menu": "null", "TakeOut": "true", "PriceRange": "1.0", "HappyHour": "null", "review_count": "10", "sponsored": null, "stars": 2.5} The Embedding model sees this: Metadata: restaurant_id=>40366661 attributes=>{"Alcohol": "'none'", "Ambience": "{'romantic': False, 'intimate': False, 'classy': False, 'hipster': False, 'divey': False, 'touristy': False, 'trendy': False, 'upscale': False, 'casual': False}", "BYOB": null, "BestNights": null, "BikeParking": null, "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": null, "BusinessParking": "None", "Caters": "True", "DriveThru": null, "GoodForDancing": null, "GoodForKids": "True", "GoodForMeal": null, "HasTV": "True", "Music": null, "NoiseLevel": "'average'", "RestaurantsAttire": "'casual'", "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "True", "RestaurantsTableService": "False", "WheelchairAccessible": "True", "WiFi": "'free'"} cuisine=>"Tex-Mex" DogsAllowed=>None OutdoorSeating=>True borough=>"Manhattan" address=>{"building": "627", "coord": [-73.975981, 40.745132], "street": "2 Avenue", "zipcode": "10016"} _id=>{'$oid': '6095a34a7c34416a90d3206b'} name=>"Baby Bo'S Burritos" menu=>null TakeOut=>true PriceRange=>1.0 HappyHour=>null review_count=>10 sponsored=>None stars=>2.5 ----- Content: {"restaurant_id": "40366661", "attributes": "{\"Alcohol\": \"'none'\", \"Ambience\": \"{'romantic': False, 'intimate': False, 'classy': False, 'hipster': False, 'divey': False, 'touristy': False, 'trendy': False, 'upscale': False, 'casual': False}\", \"BYOB\": null, \"BestNights\": null, \"BikeParking\": null, \"BusinessAcceptsBitcoin\": null, \"BusinessAcceptsCreditCards\": null, \"BusinessParking\": \"None\", \"Caters\": \"True\", \"DriveThru\": null, \"GoodForDancing\": null, \"GoodForKids\": \"True\", \"GoodForMeal\": null, \"HasTV\": \"True\", \"Music\": null, \"NoiseLevel\": \"'average'\", \"RestaurantsAttire\": \"'casual'\", \"RestaurantsDelivery\": \"True\", \"RestaurantsGoodForGroups\": \"True\", \"RestaurantsReservations\": \"True\", \"RestaurantsTableService\": \"False\", \"WheelchairAccessible\": \"True\", \"WiFi\": \"'free'\"}", "cuisine": "\"Tex-Mex\"", "DogsAllowed": null, "OutdoorSeating": true, "borough": "\"Manhattan\"", "address": "{\"building\": \"627\", \"coord\": [-73.975981, 40.745132], \"street\": \"2 Avenue\", \"zipcode\": \"10016\"}", "_id": {"$oid": "6095a34a7c34416a90d3206b"}, "name": "\"Baby Bo'S Burritos\"", "menu": "null", "TakeOut": "true", "PriceRange": "1.0", "HappyHour": "null", "review_count": "10", "sponsored": null, "stars": 2.5}
In [ ]
已复制!
llama_documents[0]
llama_documents[0]
Out[ ]
Document(id_='93d3f08d-85f3-494d-a057-19bc834abc29', embedding=None, metadata={'restaurant_id': '40366661', 'attributes': '{"Alcohol": "\'none\'", "Ambience": "{\'romantic\': False, \'intimate\': False, \'classy\': False, \'hipster\': False, \'divey\': False, \'touristy\': False, \'trendy\': False, \'upscale\': False, \'casual\': False}", "BYOB": null, "BestNights": null, "BikeParking": null, "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": null, "BusinessParking": "None", "Caters": "True", "DriveThru": null, "GoodForDancing": null, "GoodForKids": "True", "GoodForMeal": null, "HasTV": "True", "Music": null, "NoiseLevel": "\'average\'", "RestaurantsAttire": "\'casual\'", "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "True", "RestaurantsTableService": "False", "WheelchairAccessible": "True", "WiFi": "\'free\'"}', 'cuisine': '"Tex-Mex"', 'DogsAllowed': None, 'OutdoorSeating': True, 'borough': '"Manhattan"', 'address': '{"building": "627", "coord": [-73.975981, 40.745132], "street": "2 Avenue", "zipcode": "10016"}', '_id': {'$oid': '6095a34a7c34416a90d3206b'}, 'name': '"Baby Bo\'S Burritos"', 'menu': 'null', 'TakeOut': 'true', 'PriceRange': '1.0', 'HappyHour': 'null', 'review_count': '10', 'sponsored': None, 'stars': 2.5}, excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={}, text='{"restaurant_id": "40366661", "attributes": "{\\"Alcohol\\": \\"\'none\'\\", \\"Ambience\\": \\"{\'romantic\': False, \'intimate\': False, \'classy\': False, \'hipster\': False, \'divey\': False, \'touristy\': False, \'trendy\': False, \'upscale\': False, \'casual\': False}\\", \\"BYOB\\": null, \\"BestNights\\": null, \\"BikeParking\\": null, \\"BusinessAcceptsBitcoin\\": null, \\"BusinessAcceptsCreditCards\\": null, \\"BusinessParking\\": \\"None\\", \\"Caters\\": \\"True\\", \\"DriveThru\\": null, \\"GoodForDancing\\": null, \\"GoodForKids\\": \\"True\\", \\"GoodForMeal\\": null, \\"HasTV\\": \\"True\\", \\"Music\\": null, \\"NoiseLevel\\": \\"\'average\'\\", \\"RestaurantsAttire\\": \\"\'casual\'\\", \\"RestaurantsDelivery\\": \\"True\\", \\"RestaurantsGoodForGroups\\": \\"True\\", \\"RestaurantsReservations\\": \\"True\\", \\"RestaurantsTableService\\": \\"False\\", \\"WheelchairAccessible\\": \\"True\\", \\"WiFi\\": \\"\'free\'\\"}", "cuisine": "\\"Tex-Mex\\"", "DogsAllowed": null, "OutdoorSeating": true, "borough": "\\"Manhattan\\"", "address": "{\\"building\\": \\"627\\", \\"coord\\": [-73.975981, 40.745132], \\"street\\": \\"2 Avenue\\", \\"zipcode\\": \\"10016\\"}", "_id": {"$oid": "6095a34a7c34416a90d3206b"}, "name": "\\"Baby Bo\'S Burritos\\"", "menu": "null", "TakeOut": "true", "PriceRange": "1.0", "HappyHour": "null", "review_count": "10", "sponsored": null, "stars": 2.5}', start_char_idx=None, end_char_idx=None, text_template='Metadata: {metadata_str}\n-----\nContent: {content}', metadata_template='{key}=>{value}', metadata_seperator='\n')
In [ ]
已复制!
from llama_index.core.node_parser import SentenceSplitter
parser = SentenceSplitter()
nodes = parser.get_nodes_from_documents(llama_documents)
# 25k nodes takes about 10 minutes, will trim it down to 2.5k
new_nodes = nodes[:2500]
# There are 25k documents, so we need to do batching. Fortunately LlamaIndex provides good batching
# for embedding models, and we are going to rely on the __call__ method for the model to handle this
node_embeddings = embed_model(new_nodes)
from llama_index.core.node_parser import SentenceSplitter parser = SentenceSplitter() nodes = parser.get_nodes_from_documents(llama_documents) # 25k nodes takes about 10 minutes, will trim it down to 2.5k new_nodes = nodes[:2500] # There are 25k documents, so we need to do batching. Fortunately LlamaIndex provides good batching # for embedding models, and we are going to rely on the __call__ method for the model to handle this node_embeddings = embed_model(new_nodes)
In [ ]
已复制!
for idx, n in enumerate(new_nodes):
n.embedding = node_embeddings[idx].embedding
if "_id" in n.metadata:
del n.metadata["_id"]
for idx, n in enumerate(new_nodes): n.embedding = node_embeddings[idx].embedding if "_id" in n.metadata: del n.metadata["_id"]
请确保您已在 MongoDB Atlas 上为集合设置了数据库、集合和向量存储索引,否则后续步骤将无法正常工作。
In [ ]
已复制!
import pymongo
def get_mongo_client(mongo_uri):
"""Establish connection to the MongoDB."""
try:
client = pymongo.MongoClient(mongo_uri)
print("Connection to MongoDB successful")
return client
except pymongo.errors.ConnectionFailure as e:
print(f"Connection failed: {e}")
return None
# set up Fireworks.ai Key
import os
import getpass
mongo_uri = getpass.getpass("MONGO_URI:")
if not mongo_uri:
print("MONGO_URI not set")
mongo_client = get_mongo_client(mongo_uri)
DB_NAME = "whatscooking"
COLLECTION_NAME = "restaurants"
db = mongo_client[DB_NAME]
collection = db[COLLECTION_NAME]
import pymongo def get_mongo_client(mongo_uri): """Establish connection to the MongoDB.""" try: client = pymongo.MongoClient(mongo_uri) print("Connection to MongoDB successful") return client except pymongo.errors.ConnectionFailure as e: print(f"Connection failed: {e}") return None # set up Fireworks.ai Key import os import getpass mongo_uri = getpass.getpass("MONGO_URI:") if not mongo_uri: print("MONGO_URI not set") mongo_client = get_mongo_client(mongo_uri) DB_NAME = "whatscooking" COLLECTION_NAME = "restaurants" db = mongo_client[DB_NAME] collection = db[COLLECTION_NAME]
Connection to MongoDB successful
In [ ]
已复制!
# To ensure we are working with a fresh collection
# delete any existing records in the collection
collection.delete_many({})
# To ensure we are working with a fresh collection # delete any existing records in the collection collection.delete_many({})
Out[ ]
DeleteResult({'n': 0, 'electionId': ObjectId('7fffffff00000000000001ce'), 'opTime': {'ts': Timestamp(1708970193, 3), 't': 462}, 'ok': 1.0, '$clusterTime': {'clusterTime': Timestamp(1708970193, 3), 'signature': {'hash': b'\x9a3H8\xa1\x1b\xb6\xbb\xa9\xc3x\x17\x1c\xeb\xe9\x03\xaa\xf8\xf17', 'keyId': 7294687148333072386}}, 'operationTime': Timestamp(1708970193, 3)}, acknowledged=True)
In [ ]
已复制!
from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch
vector_store = MongoDBAtlasVectorSearch(
mongo_client,
db_name=DB_NAME,
collection_name=COLLECTION_NAME,
index_name="vector_index",
)
vector_store.add(new_nodes)
from llama_index.vector_stores.mongodb import MongoDBAtlasVectorSearch vector_store = MongoDBAtlasVectorSearch( mongo_client, db_name=DB_NAME, collection_name=COLLECTION_NAME, index_name="vector_index", ) vector_store.add(new_nodes)
现在请确保您在这里使用正确的名称创建了搜索索引
In [ ]
已复制!
from llama_index.core import VectorStoreIndex, StorageContext
index = VectorStoreIndex.from_vector_store(vector_store)
from llama_index.core import VectorStoreIndex, StorageContext index = VectorStoreIndex.from_vector_store(vector_store)
In [ ]
已复制!
%pip install -q matplotlib
%pip install -q matplotlib
Note: you may need to restart the kernel to use updated packages.
In [ ]
已复制!
import pprint
from llama_index.core.response.notebook_utils import display_response
query_engine = index.as_query_engine()
query = "search query: Anything that doesn't have alcohol in it"
response = query_engine.query(query)
display_response(response)
pprint.pprint(response.source_nodes)
import pprint from llama_index.core.response.notebook_utils import display_response query_engine = index.as_query_engine() query = "search query: Anything that doesn't have alcohol in it" response = query_engine.query(query) display_response(response) pprint.pprint(response.source_nodes)
最终响应:
根据提供的上下文,不提供酒精饮品的两家餐厅选项是
位于布鲁克林的“Academy Restaurant”,提供美式菜肴和各种菜品,例如马苏里拉芝士条、芝士汉堡、烤土豆、面包棒、凯撒沙拉、帕玛森鸡肉、培根卷香肠、鸡汤、通心粉加芝士、蘑菇瑞士汉堡、肉丸意面和土豆泥。
位于曼哈顿的“Gabriel's Bar & Grill”,专门提供意大利菜,提供芝士馄饨、那不勒斯披萨、什锦冰淇淋、素烤通心粉、素花椰菜披萨、烤宽面条、Buca Trio 拼盘、菠菜馄饨、意面配意大利乳清干酪、意大利面条、炸鱿鱼和阿尔弗雷多披萨等菜肴。
这两家餐厅都提供户外座位,适合儿童,并且着装要求随意。它们还提供外卖服务,并有欢乐时光促销活动。
[NodeWithScore(node=TextNode(id_='5405e68c-19f2-4a65-95d7-f880fa6a8deb', embedding=None, metadata={'restaurant_id': '40385767', 'attributes': '{"Alcohol": "u\'beer_and_wine\'", "Ambience": "{\'touristy\': False, \'hipster\': False, \'romantic\': False, \'divey\': False, \'intimate\': None, \'trendy\': None, \'upscale\': False, \'classy\': False, \'casual\': True}", "BYOB": null, "BestNights": "{\'monday\': False, \'tuesday\': False, \'friday\': True, \'wednesday\': False, \'thursday\': False, \'sunday\': False, \'saturday\': True}", "BikeParking": "True", "BusinessAcceptsBitcoin": "False", "BusinessAcceptsCreditCards": "True", "BusinessParking": "{\'garage\': False, \'street\': False, \'validated\': False, \'lot\': True, \'valet\': False}", "Caters": "True", "DriveThru": null, "GoodForDancing": "False", "GoodForKids": "True", "GoodForMeal": "{\'dessert\': False, \'latenight\': False, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}", "HasTV": "True", "Music": "{\'dj\': False, \'background_music\': False, \'no_music\': False, \'jukebox\': False, \'live\': False, \'video\': False, \'karaoke\': False}", "NoiseLevel": "u\'average\'", "RestaurantsAttire": "u\'casual\'", "RestaurantsDelivery": "None", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "True", "RestaurantsTableService": "True", "WheelchairAccessible": "True", "WiFi": "u\'free\'"}', 'cuisine': '"American"', 'DogsAllowed': True, 'OutdoorSeating': True, 'borough': '"Brooklyn"', 'address': '{"building": "69", "coord": [-73.9757464, 40.687295], "street": "Lafayette Avenue", "zipcode": "11217"}', 'name': '"Academy Restauraunt"', 'menu': '["Mozzarella sticks", "Cheeseburger", "Baked potato", "Breadsticks", "Caesar salad", "Chicken parmesan", "Pigs in a blanket", "Chicken soup", "Mac & cheese", "Mushroom swiss burger", "Spaghetti with meatballs", "Mashed potatoes"]', 'TakeOut': 'true', 'PriceRange': '2.0', 'HappyHour': 'true', 'review_count': '173', 'sponsored': None, 'stars': 4.5}, excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='bbfc4bf5-d9c3-4f3b-8c1f-ddcf94f3b5df', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'restaurant_id': '40385767', 'attributes': '{"Alcohol": "u\'beer_and_wine\'", "Ambience": "{\'touristy\': False, \'hipster\': False, \'romantic\': False, \'divey\': False, \'intimate\': None, \'trendy\': None, \'upscale\': False, \'classy\': False, \'casual\': True}", "BYOB": null, "BestNights": "{\'monday\': False, \'tuesday\': False, \'friday\': True, \'wednesday\': False, \'thursday\': False, \'sunday\': False, \'saturday\': True}", "BikeParking": "True", "BusinessAcceptsBitcoin": "False", "BusinessAcceptsCreditCards": "True", "BusinessParking": "{\'garage\': False, \'street\': False, \'validated\': False, \'lot\': True, \'valet\': False}", "Caters": "True", "DriveThru": null, "GoodForDancing": "False", "GoodForKids": "True", "GoodForMeal": "{\'dessert\': False, \'latenight\': False, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}", "HasTV": "True", "Music": "{\'dj\': False, \'background_music\': False, \'no_music\': False, \'jukebox\': False, \'live\': False, \'video\': False, \'karaoke\': False}", "NoiseLevel": "u\'average\'", "RestaurantsAttire": "u\'casual\'", "RestaurantsDelivery": "None", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "True", "RestaurantsTableService": "True", "WheelchairAccessible": "True", "WiFi": "u\'free\'"}', 'cuisine': '"American"', 'DogsAllowed': True, 'OutdoorSeating': True, 'borough': '"Brooklyn"', 'address': '{"building": "69", "coord": [-73.9757464, 40.687295], "street": "Lafayette Avenue", "zipcode": "11217"}', '_id': {'$oid': '6095a34a7c34416a90d322d1'}, 'name': '"Academy Restauraunt"', 'menu': '["Mozzarella sticks", "Cheeseburger", "Baked potato", "Breadsticks", "Caesar salad", "Chicken parmesan", "Pigs in a blanket", "Chicken soup", "Mac & cheese", "Mushroom swiss burger", "Spaghetti with meatballs", "Mashed potatoes"]', 'TakeOut': 'true', 'PriceRange': '2.0', 'HappyHour': 'true', 'review_count': '173', 'sponsored': None, 'stars': 4.5}, hash='df7870b3103572b05e98091e4d4b52b238175eb08558831b621b6832c0472c2e'), <NodeRelationship.PREVIOUS: '2'>: RelatedNodeInfo(node_id='5fbb14fe-c8a8-4c4c-930d-2e07e4f77b47', node_type=<ObjectType.TEXT: '1'>, metadata={'restaurant_id': '40377111', 'attributes': '{"Alcohol": null, "Ambience": null, "BYOB": null, "BestNights": null, "BikeParking": "True", "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": "False", "BusinessParking": "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}", "Caters": null, "DriveThru": "True", "GoodForDancing": null, "GoodForKids": null, "GoodForMeal": null, "HasTV": null, "Music": null, "NoiseLevel": null, "RestaurantsAttire": null, "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": null, "RestaurantsReservations": null, "RestaurantsTableService": null, "WheelchairAccessible": null, "WiFi": null}', 'cuisine': '"American"', 'DogsAllowed': None, 'OutdoorSeating': None, 'borough': '"Manhattan"', 'address': '{"building": "1207", "coord": [-73.9592644, 40.8088612], "street": "Amsterdam Avenue", "zipcode": "10027"}', '_id': {'$oid': '6095a34a7c34416a90d321d6'}, 'name': '"Amsterdam Restaurant & Tapas Lounge"', 'menu': '["Green salad", "Cheddar Biscuits", "Lasagna", "Chicken parmesan", "Chicken soup", "Pigs in a blanket", "Caesar salad", "French fries", "Baked potato", "Mushroom swiss burger", "Grilled cheese sandwich", "Fried chicken"]', 'TakeOut': 'true', 'PriceRange': '1.0', 'HappyHour': 'null', 'review_count': '6', 'sponsored': None, 'stars': 5.0}, hash='1261332dd67be495d0639f41b5f6462f87a41aabe20367502ef28074bf13e561'), <NodeRelationship.NEXT: '3'>: RelatedNodeInfo(node_id='10ad1a23-3237-4b68-808d-58fd7b7e5cb6', node_type=<ObjectType.TEXT: '1'>, metadata={}, hash='bc64dca2f9210693c3d5174aec305f25b68d080be65a0ae52f9a560f99992bb0')}, text='{"restaurant_id": "40385767", "attributes": "{\\"Alcohol\\": \\"u\'beer_and_wine\'\\", \\"Ambience\\": \\"{\'touristy\': False, \'hipster\': False, \'romantic\': False, \'divey\': False, \'intimate\': None, \'trendy\': None, \'upscale\': False, \'classy\': False, \'casual\': True}\\", \\"BYOB\\": null, \\"BestNights\\": \\"{\'monday\': False, \'tuesday\': False, \'friday\': True, \'wednesday\': False, \'thursday\': False, \'sunday\': False, \'saturday\': True}\\", \\"BikeParking\\": \\"True\\", \\"BusinessAcceptsBitcoin\\": \\"False\\", \\"BusinessAcceptsCreditCards\\": \\"True\\", \\"BusinessParking\\": \\"{\'garage\': False, \'street\': False, \'validated\': False, \'lot\': True, \'valet\': False}\\", \\"Caters\\": \\"True\\", \\"DriveThru\\": null, \\"GoodForDancing\\": \\"False\\", \\"GoodForKids\\": \\"True\\", \\"GoodForMeal\\": \\"{\'dessert\': False, \'latenight\': False, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}\\", \\"HasTV\\": \\"True\\", \\"Music\\": \\"{\'dj\': False, \'background_music\': False, \'no_music\': False, \'jukebox\': False, \'live\': False, \'video\': False, \'karaoke\': False}\\", \\"NoiseLevel\\": \\"u\'average\'\\", \\"RestaurantsAttire\\": \\"u\'casual\'\\", \\"RestaurantsDelivery\\": \\"None\\", \\"RestaurantsGoodForGroups\\": \\"True\\", \\"RestaurantsReservations\\": \\"True\\", \\"RestaurantsTableService\\": \\"True\\", \\"WheelchairAccessible\\": \\"True\\", \\"WiFi\\": \\"u\'free\'\\"}", "cuisine": "\\"American\\"", "DogsAllowed": true, "OutdoorSeating": true, "borough": "\\"Brooklyn\\"",', start_char_idx=0, end_char_idx=1415, text_template='Metadata: {metadata_str}\n-----\nContent: {content}', metadata_template='{key}=>{value}', metadata_seperator='\n'), score=0.7296431064605713), NodeWithScore(node=TextNode(id_='9cd153ba-2ab8-40aa-90f0-9da5ae24c632', embedding=None, metadata={'restaurant_id': '40392690', 'attributes': '{"Alcohol": "u\'full_bar\'", "Ambience": "{\'touristy\': None, \'hipster\': True, \'romantic\': False, \'divey\': False, \'intimate\': None, \'trendy\': True, \'upscale\': None, \'classy\': True, \'casual\': True}", "BYOB": "False", "BestNights": "{\'monday\': False, \'tuesday\': False, \'friday\': True, \'wednesday\': False, \'thursday\': False, \'sunday\': False, \'saturday\': False}", "BikeParking": "True", "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": "True", "BusinessParking": "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}", "Caters": "True", "DriveThru": "False", "GoodForDancing": "False", "GoodForKids": "True", "GoodForMeal": "{\'dessert\': None, \'latenight\': None, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}", "HasTV": "False", "Music": "{\'dj\': False, \'background_music\': False, \'no_music\': False, \'jukebox\': False, \'live\': False, \'video\': False, \'karaoke\': False}", "NoiseLevel": "u\'average\'", "RestaurantsAttire": "\'casual\'", "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "False", "RestaurantsTableService": "True", "WheelchairAccessible": "True", "WiFi": "\'free\'"}', 'cuisine': '"Italian"', 'DogsAllowed': True, 'OutdoorSeating': True, 'borough': '"Manhattan"', 'address': '{"building": "11", "coord": [-73.9828696, 40.7693649], "street": "West 60 Street", "zipcode": "10023"}', 'name': '"Gabriel\'S Bar & Grill"', 'menu': '["Cheese Ravioli", "Neapolitan Pizza", "assorted gelato", "Vegetarian Baked Ziti", "Vegetarian Broccoli Pizza", "Lasagna", "Buca Trio Platter", "Spinach Ravioli", "Pasta with ricotta cheese", "Spaghetti", "Fried calimari", "Alfredo Pizza"]', 'TakeOut': 'true', 'PriceRange': '2.0', 'HappyHour': 'true', 'review_count': '333', 'sponsored': None, 'stars': 4.0}, excluded_embed_metadata_keys=[], excluded_llm_metadata_keys=[], relationships={<NodeRelationship.SOURCE: '1'>: RelatedNodeInfo(node_id='77584933-8286-4277-bc56-bed76adcfd37', node_type=<ObjectType.DOCUMENT: '4'>, metadata={'restaurant_id': '40392690', 'attributes': '{"Alcohol": "u\'full_bar\'", "Ambience": "{\'touristy\': None, \'hipster\': True, \'romantic\': False, \'divey\': False, \'intimate\': None, \'trendy\': True, \'upscale\': None, \'classy\': True, \'casual\': True}", "BYOB": "False", "BestNights": "{\'monday\': False, \'tuesday\': False, \'friday\': True, \'wednesday\': False, \'thursday\': False, \'sunday\': False, \'saturday\': False}", "BikeParking": "True", "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": "True", "BusinessParking": "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}", "Caters": "True", "DriveThru": "False", "GoodForDancing": "False", "GoodForKids": "True", "GoodForMeal": "{\'dessert\': None, \'latenight\': None, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}", "HasTV": "False", "Music": "{\'dj\': False, \'background_music\': False, \'no_music\': False, \'jukebox\': False, \'live\': False, \'video\': False, \'karaoke\': False}", "NoiseLevel": "u\'average\'", "RestaurantsAttire": "\'casual\'", "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": "True", "RestaurantsReservations": "False", "RestaurantsTableService": "True", "WheelchairAccessible": "True", "WiFi": "\'free\'"}', 'cuisine': '"Italian"', 'DogsAllowed': True, 'OutdoorSeating': True, 'borough': '"Manhattan"', 'address': '{"building": "11", "coord": [-73.9828696, 40.7693649], "street": "West 60 Street", "zipcode": "10023"}', '_id': {'$oid': '6095a34b7c34416a90d3243a'}, 'name': '"Gabriel\'S Bar & Grill"', 'menu': '["Cheese Ravioli", "Neapolitan Pizza", "assorted gelato", "Vegetarian Baked Ziti", "Vegetarian Broccoli Pizza", "Lasagna", "Buca Trio Platter", "Spinach Ravioli", "Pasta with ricotta cheese", "Spaghetti", "Fried calimari", "Alfredo Pizza"]', 'TakeOut': 'true', 'PriceRange': '2.0', 'HappyHour': 'true', 'review_count': '333', 'sponsored': None, 'stars': 4.0}, hash='c4dcc57a697cd2fe3047a280573c0f54bc5236e1d5af2228737af77613c9dbf7'), <NodeRelationship.PREVIOUS: '2'>: RelatedNodeInfo(node_id='6e1ead27-3679-48fb-b160-b47db523a3ce', node_type=<ObjectType.TEXT: '1'>, metadata={'restaurant_id': '40392496', 'attributes': '{"Alcohol": "u\'none\'", "Ambience": "{\'touristy\': False, \'hipster\': False, \'romantic\': False, \'intimate\': None, \'trendy\': False, \'upscale\': False, \'classy\': False, \'casual\': True}", "BYOB": null, "BestNights": null, "BikeParking": "True", "BusinessAcceptsBitcoin": null, "BusinessAcceptsCreditCards": null, "BusinessParking": "{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}", "Caters": "False", "DriveThru": null, "GoodForDancing": null, "GoodForKids": "True", "GoodForMeal": "{\'dessert\': False, \'latenight\': False, \'lunch\': True, \'dinner\': True, \'brunch\': None, \'breakfast\': False}", "HasTV": "True", "Music": null, "NoiseLevel": "u\'average\'", "RestaurantsAttire": "u\'casual\'", "RestaurantsDelivery": "True", "RestaurantsGoodForGroups": "False", "RestaurantsReservations": "False", "RestaurantsTableService": "True", "WheelchairAccessible": null, "WiFi": "\'free\'"}', 'cuisine': '"English"', 'DogsAllowed': True, 'OutdoorSeating': True, 'borough': '"Manhattan"', 'address': '{"building": "253", "coord": [-74.0034571, 40.736351], "street": "West 11 Street", "zipcode": "10014"}', '_id': {'$oid': '6095a34b7c34416a90d32435'}, 'name': '"Tartine"', 'menu': 'null', 'TakeOut': 'true', 'PriceRange': '2.0', 'HappyHour': 'true', 'review_count': '436', 'sponsored': None, 'stars': 4.5}, hash='146bffad5c816926ec1008d966caab7c0df675251ccca5de860f8a2160bb7a34'), <NodeRelationship.NEXT: '3'>: RelatedNodeInfo(node_id='6640911b-3d8e-4bad-a016-4c3d91444b0c', node_type=<ObjectType.TEXT: '1'>, metadata={}, hash='39984a7534d6755344f0887e0d6a200eaab562a7dc492afe292040c0022282bd')}, text='{"restaurant_id": "40392690", "attributes": "{\\"Alcohol\\": \\"u\'full_bar\'\\", \\"Ambience\\": \\"{\'touristy\': None, \'hipster\': True, \'romantic\': False, \'divey\': False, \'intimate\': None, \'trendy\': True, \'upscale\': None, \'classy\': True, \'casual\': True}\\", \\"BYOB\\": \\"False\\", \\"BestNights\\": \\"{\'monday\': False, \'tuesday\': False, \'friday\': True, \'wednesday\': False, \'thursday\': False, \'sunday\': False, \'saturday\': False}\\", \\"BikeParking\\": \\"True\\", \\"BusinessAcceptsBitcoin\\": null, \\"BusinessAcceptsCreditCards\\": \\"True\\", \\"BusinessParking\\": \\"{\'garage\': False, \'street\': True, \'validated\': False, \'lot\': False, \'valet\': False}\\", \\"Caters\\": \\"True\\", \\"DriveThru\\": \\"False\\", \\"GoodForDancing\\": \\"False\\", \\"GoodForKids\\": \\"True\\", \\"GoodForMeal\\": \\"{\'dessert\': None, \'latenight\': None, \'lunch\': True, \'dinner\': True, \'brunch\': False, \'breakfast\': False}\\", \\"HasTV\\": \\"False\\", \\"Music\\": \\"{\'dj\': False, \'background_music\': False, \'no_music\': False, \'jukebox\': False, \'live\': False, \'video\': False, \'karaoke\': False}\\", \\"NoiseLevel\\": \\"u\'average\'\\", \\"RestaurantsAttire\\": \\"\'casual\'\\", \\"RestaurantsDelivery\\": \\"True\\", \\"RestaurantsGoodForGroups\\": \\"True\\", \\"RestaurantsReservations\\": \\"False\\", \\"RestaurantsTableService\\": \\"True\\", \\"WheelchairAccessible\\": \\"True\\", \\"WiFi\\": \\"\'free\'\\"}", "cuisine": "\\"Italian\\"", "DogsAllowed": true, "OutdoorSeating": true,', start_char_idx=0, end_char_idx=1382, text_template='Metadata: {metadata_str}\n-----\nContent: {content}', metadata_template='{key}=>{value}', metadata_seperator='\n'), score=0.7284677028656006)]