Miroir commited on
Commit
cba26e9
·
1 Parent(s): d3fa1fe

test endpoints

Browse files
Files changed (1) hide show
  1. app.py +70 -0
app.py CHANGED
@@ -56,6 +56,73 @@ class WordCheck(BaseModel):
56
  class JokerUse(BaseModel):
57
  joker_type: str
58
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  @app.get("/api/game-state")
60
  async def get_game_state():
61
  try:
@@ -101,6 +168,9 @@ async def get_visualization():
101
  logger.error(f"Error getting visualization: {str(e)}")
102
  raise HTTPException(status_code=500, detail="Internal server error")
103
 
 
 
 
104
  @app.get("/")
105
  async def root():
106
  """Health check endpoint"""
 
56
  class JokerUse(BaseModel):
57
  joker_type: str
58
 
59
+
60
+ # After your imports and before the main endpoints, add:
61
+
62
+ @app.get("/api/test/ping")
63
+ async def ping():
64
+ """Basic ping endpoint to check if the service is responding"""
65
+ return {"status": "ok", "message": "pong"}
66
+
67
+ @app.get("/api/test/model")
68
+ async def test_model():
69
+ """Test if the word embedding model is loaded and working"""
70
+ try:
71
+ # Test basic similarity calculation
72
+ similarity = word_service.calculate_similarity("bonjour", "salut")
73
+ return {
74
+ "status": "ok",
75
+ "message": "Model is working",
76
+ "test_similarity": {
77
+ "word1": "bonjour",
78
+ "word2": "salut",
79
+ "similarity": similarity
80
+ }
81
+ }
82
+ except Exception as e:
83
+ logger.error(f"Model test failed: {str(e)}")
84
+ return {
85
+ "status": "error",
86
+ "message": str(e)
87
+ }
88
+
89
+ @app.get("/api/test/env")
90
+ async def test_environment():
91
+ """Get information about the running environment"""
92
+ return {
93
+ "status": "ok",
94
+ "environment": {
95
+ "python_version": platform.python_version(),
96
+ "host": socket.gethostname(),
97
+ "model_url": os.getenv('MODEL_URL'),
98
+ "services_initialized": {
99
+ "word_service": word_service is not None,
100
+ "game_service": game_service is not None,
101
+ "visualization_service": visualization_service is not None
102
+ }
103
+ }
104
+ }
105
+
106
+ @app.get("/api/test/model-info")
107
+ async def test_model_info():
108
+ """Get information about the loaded model"""
109
+ try:
110
+ vocab_size = len(word_service.vocab_vectors)
111
+ sample_words = list(word_service.vocab_vectors.keys())[:5] # Get first 5 words
112
+ return {
113
+ "status": "ok",
114
+ "model_info": {
115
+ "vocabulary_size": vocab_size,
116
+ "sample_words": sample_words,
117
+ }
118
+ }
119
+ except Exception as e:
120
+ logger.error(f"Error getting model info: {str(e)}")
121
+ return {
122
+ "status": "error",
123
+ "message": str(e)
124
+ }
125
+
126
  @app.get("/api/game-state")
127
  async def get_game_state():
128
  try:
 
168
  logger.error(f"Error getting visualization: {str(e)}")
169
  raise HTTPException(status_code=500, detail="Internal server error")
170
 
171
+
172
+
173
+
174
  @app.get("/")
175
  async def root():
176
  """Health check endpoint"""