mirror of
				https://github.com/serge-chat/serge.git
				synced 2024-01-15 09:32:12 +03:00 
			
		
		
		
	Add /ping route to API (#685)
This commit is contained in:
		 Juan Calderon-Perez
					Juan Calderon-Perez
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							0500cb2266
						
					
				
				
					commit
					0acf8e0911
				
			| @@ -32,13 +32,15 @@ COPY scripts/deploy.sh /usr/src/app/deploy.sh | ||||
|  | ||||
| # Install api dependencies | ||||
| RUN apt-get update \ | ||||
|     && apt-get install -y --no-install-recommends cmake build-essential dumb-init \ | ||||
|     && apt-get install -y --no-install-recommends cmake build-essential dumb-init curl \ | ||||
|     && pip install --no-cache-dir ./api \ | ||||
|     && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* \ | ||||
|     && chmod 755 /usr/src/app/deploy.sh \ | ||||
|     && chmod 755 /usr/local/bin/redis-server \ | ||||
|     && chmod 755 /usr/local/bin/redis-cli \ | ||||
|     && mkdir -p /etc/redis \ | ||||
|     && mkdir -p /data/db \ | ||||
|     && mkdir -p /usr/src/app/weights \ | ||||
|     && echo "appendonly yes" >> /etc/redis/redis.conf \ | ||||
|     && echo "dir /data/db/" >> /etc/redis/redis.conf | ||||
|  | ||||
|   | ||||
| @@ -17,7 +17,7 @@ ENV NODE_ENV='development' | ||||
|  | ||||
| # Install dependencies | ||||
| RUN apt-get update \ | ||||
|     && apt-get install -y --no-install-recommends cmake build-essential dumb-init | ||||
|     && apt-get install -y --no-install-recommends cmake build-essential dumb-init curl | ||||
|  | ||||
| # Copy database, source code, and scripts | ||||
| COPY --from=redis /usr/local/bin/redis-server /usr/local/bin/redis-server | ||||
| @@ -31,6 +31,8 @@ RUN npm ci \ | ||||
|     && chmod 755 /usr/local/bin/redis-server \ | ||||
|     && chmod 755 /usr/local/bin/redis-cli \ | ||||
|     && mkdir -p /etc/redis \ | ||||
|     && mkdir -p /data/db \ | ||||
|     && mkdir -p /usr/src/app/weights \ | ||||
|     && echo "appendonly yes" >> /etc/redis/redis.conf \ | ||||
|     && echo "dir /data/db/" >> /etc/redis/redis.conf | ||||
|  | ||||
|   | ||||
| @@ -10,6 +10,7 @@ from starlette.responses import FileResponse | ||||
| from serge.models.settings import Settings | ||||
| from serge.routers.chat import chat_router | ||||
| from serge.routers.model import model_router | ||||
| from serge.routers.ping import ping_router | ||||
| from serge.utils.convert import convert_all | ||||
|  | ||||
| # Configure logging settings | ||||
| @@ -45,6 +46,7 @@ app = FastAPI(title="Serge", version="0.0.1", description=description, tags_meta | ||||
|  | ||||
| api_app = FastAPI(title="Serge API") | ||||
| api_app.include_router(chat_router) | ||||
| api_app.include_router(ping_router) | ||||
| api_app.include_router(model_router) | ||||
| app.mount("/api", api_app) | ||||
|  | ||||
|   | ||||
							
								
								
									
										11
									
								
								api/src/serge/routers/ping.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								api/src/serge/routers/ping.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| from fastapi import APIRouter | ||||
|  | ||||
| ping_router = APIRouter( | ||||
|     prefix="/ping", | ||||
|     tags=["ping"], | ||||
| ) | ||||
|  | ||||
|  | ||||
| @ping_router.get("/") | ||||
| def pong(): | ||||
|     return {"message": "pong!"} | ||||
| @@ -23,5 +23,4 @@ for family in families: | ||||
| def test_model_available(repo, filename): | ||||
|     url = huggingface_hub.hf_hub_url(repo, filename, repo_type="model", revision="main") | ||||
|     r = requests.head(url) | ||||
|  | ||||
|     assert r.ok, f"Model {repo}/{filename} not available" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user