Pepguy commited on
Commit
f40dde7
·
verified ·
1 Parent(s): 05fc12b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -5,6 +5,7 @@ from fastapi import FastAPI, HTTPException
5
  from pydantic import BaseModel, Field
6
  from sklearn.neighbors import KDTree
7
  import numpy as np
 
8
 
9
  # Configurable number of scales
10
  NUM_SCALES = 8
@@ -96,16 +97,15 @@ def recommend(user_id: str, region_radius: float = 0.2, top_k: int = 5):
96
  ]
97
 
98
  # Sample test data when run directly
99
- if __name__ == "__main__":
100
- # Install dependencies: fastapi, uvicorn, numpy, scikit-learn, pydantic
101
- import uvicorn
102
  # Create random test users and content
103
- repo.add_user(Profile(id="user1", scales=list(np.random.rand(NUM_SCALES))))
104
- for i in range(1, 21):
105
- repo.add_content(Content(
106
  id=f"content{i}",
107
  scales=list(np.random.rand(NUM_SCALES)),
108
  metadata={"title": f"Item {i}"}
109
  ))
110
- recommend("user1")
111
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
5
  from pydantic import BaseModel, Field
6
  from sklearn.neighbors import KDTree
7
  import numpy as np
8
+ import uvicorn
9
 
10
  # Configurable number of scales
11
  NUM_SCALES = 8
 
97
  ]
98
 
99
  # Sample test data when run directly
100
+
 
 
101
  # Create random test users and content
102
+ repo.add_user(Profile(id="user1", scales=list(np.random.rand(NUM_SCALES))))
103
+ for i in range(1, 21):
104
+ repo.add_content(Content(
105
  id=f"content{i}",
106
  scales=list(np.random.rand(NUM_SCALES)),
107
  metadata={"title": f"Item {i}"}
108
  ))
109
+ recommend("user1")
110
+ print("ran")
111
+ uvicorn.run(app, host="0.0.0.0", port=7860)