alexpantex commited on
Commit
2cd4381
·
verified ·
1 Parent(s): 8d8c002

Upload scripts/api.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. scripts/api.py +4 -5
scripts/api.py CHANGED
@@ -30,6 +30,10 @@ class QueryResponse(BaseModel):
30
  def root():
31
  return {"message": "Welcome to the Prompt Search API. Use '/search' endpoint to find similar prompts."}
32
 
 
 
 
 
33
  @app.post("/search", response_model=QueryResponse)
34
  async def search_prompts(query_request: QueryRequest):
35
  """
@@ -60,8 +64,3 @@ async def search_prompts(query_request: QueryRequest):
60
  except Exception as e:
61
  print(e)
62
  raise HTTPException(status_code=500, detail=str(e))
63
-
64
- # Entry point for configuring parameters and running the app
65
- if __name__ == "__main__":
66
- import uvicorn
67
- uvicorn.run(app, host = config["server"]["host"], port = int(os.getenv("PORT", config["server"]["port"])))
 
30
  def root():
31
  return {"message": "Welcome to the Prompt Search API. Use '/search' endpoint to find similar prompts."}
32
 
33
+ def start_api_server():
34
+ import uvicorn
35
+ uvicorn.run(app, host = config["server"]["host"], port = int(os.getenv("PORT", config["server"]["port"])))
36
+
37
  @app.post("/search", response_model=QueryResponse)
38
  async def search_prompts(query_request: QueryRequest):
39
  """
 
64
  except Exception as e:
65
  print(e)
66
  raise HTTPException(status_code=500, detail=str(e))