Hansimov commited on
Commit
48cf048
1 Parent(s): 5562491

:recycle: [Refactor] Replace /encode with /embedding for less ambiguity, and fix docker CMD

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. apps/app.py +8 -8
  3. configs/info.json +1 -1
Dockerfile CHANGED
@@ -5,4 +5,4 @@ RUN mkdir /.cache && chmod 777 /.cache
5
  RUN pip install -r requirements.txt
6
  COPY . $HOME/app
7
  EXPOSE 16666
8
- CMD ["python", "-m", "app"]
 
5
  RUN pip install -r requirements.txt
6
  COPY . $HOME/app
7
  EXPOSE 16666
8
+ CMD ["python", "-m", "apps.app"]
apps/app.py CHANGED
@@ -41,7 +41,7 @@ class EmbeddingApp:
41
  )
42
  return readme_html
43
 
44
- class EncodePostItem(BaseModel):
45
  text: Union[str, list[str]] = Field(
46
  default=None,
47
  summary="Input text(s) to embed",
@@ -51,7 +51,7 @@ class EmbeddingApp:
51
  summary="Embedding model name",
52
  )
53
 
54
- def encode(self, item: EncodePostItem):
55
  logger.note(f"> Encoding text: [{item.text}]", end=" ")
56
  if item.model != self.embedder.model:
57
  self.embedder.switch_model(item.model)
@@ -69,13 +69,13 @@ class EmbeddingApp:
69
  )(self.get_available_models)
70
 
71
  self.app.post(
72
- "/encode",
73
- summary="Encode embedding for input text",
74
- )(self.encode)
75
 
76
  self.app.get(
77
  "/readme",
78
- summary="README of HF LLM API",
79
  response_class=HTMLResponse,
80
  include_in_schema=False,
81
  )(self.get_readme)
@@ -90,14 +90,14 @@ class ArgParser(argparse.ArgumentParser):
90
  "--server",
91
  type=str,
92
  default=ENVER["server"],
93
- help=f"Server IP ({ENVER['server']}) for Embedding API",
94
  )
95
  self.add_argument(
96
  "-p",
97
  "--port",
98
  type=int,
99
  default=ENVER["port"],
100
- help=f"Server Port ({ENVER['port']}) for Embedding API",
101
  )
102
 
103
  self.args = self.parse_args(sys.argv[1:])
 
41
  )
42
  return readme_html
43
 
44
+ class CalcEmbeddingPostItem(BaseModel):
45
  text: Union[str, list[str]] = Field(
46
  default=None,
47
  summary="Input text(s) to embed",
 
51
  summary="Embedding model name",
52
  )
53
 
54
+ def calc_embedding(self, item: CalcEmbeddingPostItem):
55
  logger.note(f"> Encoding text: [{item.text}]", end=" ")
56
  if item.model != self.embedder.model:
57
  self.embedder.switch_model(item.model)
 
69
  )(self.get_available_models)
70
 
71
  self.app.post(
72
+ "/embedding",
73
+ summary="Calculate embedding for input text(s)",
74
+ )(self.calc_embedding)
75
 
76
  self.app.get(
77
  "/readme",
78
+ summary="README of Embed API",
79
  response_class=HTMLResponse,
80
  include_in_schema=False,
81
  )(self.get_readme)
 
90
  "--server",
91
  type=str,
92
  default=ENVER["server"],
93
+ help=f"Server IP ({ENVER['server']}) for Embed API",
94
  )
95
  self.add_argument(
96
  "-p",
97
  "--port",
98
  type=int,
99
  default=ENVER["port"],
100
+ help=f"Server Port ({ENVER['port']}) for Embed API",
101
  )
102
 
103
  self.args = self.parse_args(sys.argv[1:])
configs/info.json CHANGED
@@ -1,5 +1,5 @@
1
  {
2
- "version": "0.1.1",
3
  "app_name": "Embedding API",
4
  "server": "0.0.0.0",
5
  "port": 16666
 
1
  {
2
+ "version": "0.1.2",
3
  "app_name": "Embedding API",
4
  "server": "0.0.0.0",
5
  "port": 16666