-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAITOinterface.py
57 lines (47 loc) · 1.3 KB
/
AITOinterface.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import pandas as pd
import numpy as np
from aito.schema import AitoStringType, AitoTextType, AitoDelimiterAnalyzerSchema, AitoTableSchema, AitoColumnLinkSchema, AitoDatabaseSchema
from aito.client import AitoClient
import aito.api as aito_api
# aito credentials
AITO_INSTANCE_URL = 'https://team1junction.aito.app'
AITO_API_KEY = 'l9uG4dc5ha7BoqBcgT58S2Z7G7uq75ES9w6scxTM'
# define a client to access to the dataset
client = AitoClient(instance_url=AITO_INSTANCE_URL, api_key=AITO_API_KEY)
# query definition
query = {
"from": "places",
"where" : {
"cuisine" : {
"$match" : "Italian"
}
}
}
# send the query
res = aito_api.generic_query(client=client, query=query)
#print(res.to_json_string(indent=2))
# query
rec_query = {
"from": "ratings",
"where": {
"userID": {
"$or": [
{"userID": "U1022"},
{"userID": "U1026"},
{"userID": "U1024"},
{"userID": "U1025"},
]
}
},
"recommend": "placeID",
"goal" : {"rating" : 2},
"limit": 10,
}
# send query
res = aito_api.recommend(client=client, query=rec_query)
#res.json
hits = res.json['hits']
names = []
for h in hits:
names.append(h["name"])
#names