:recycle: [Refactor] Replace /encode with /embedding for less ambiguity, and fix docker CMD
Browse files- Dockerfile +1 -1
- apps/app.py +8 -8
- 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
|
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
|
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 |
-
"/
|
73 |
-
summary="
|
74 |
-
)(self.
|
75 |
|
76 |
self.app.get(
|
77 |
"/readme",
|
78 |
-
summary="README of
|
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
|
94 |
)
|
95 |
self.add_argument(
|
96 |
"-p",
|
97 |
"--port",
|
98 |
type=int,
|
99 |
default=ENVER["port"],
|
100 |
-
help=f"Server Port ({ENVER['port']}) for
|
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.
|
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
|