Skip to content

Commit 4f43125

Browse files
committed
add missing endpoints
1 parent 2b3f2ca commit 4f43125

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/codegate/providers/ollama/provider.py

+26
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,32 @@ def _setup_routes(self):
4545
"""
4646
Sets up Ollama API routes.
4747
"""
48+
@self.router.get(f"/{self.provider_route_name}/api/tags")
49+
async def get_tags(request: Request):
50+
"""
51+
Special route for /api/tags that responds outside of the pipeline
52+
Tags are used to get the list of models
53+
https://github.com/ollama/ollama/blob/main/docs/api.md#list-local-models
54+
"""
55+
async with httpx.AsyncClient() as client:
56+
response = await client.get(f"{self.base_url}/api/tags")
57+
return response.json()
58+
59+
@self.router.post(f"/{self.provider_route_name}/api/show")
60+
async def show_model(request: Request):
61+
"""
62+
route for /api/show that responds outside of the pipeline
63+
/api/show displays model is used to get the model information
64+
https://github.com/ollama/ollama/blob/main/docs/api.md#show-model-information
65+
"""
66+
body = await request.body()
67+
async with httpx.AsyncClient() as client:
68+
response = await client.post(
69+
f"{self.base_url}/api/show",
70+
content=body,
71+
headers={"Content-Type": "application/json"},
72+
)
73+
return response.json()
4874

4975
# Native Ollama API routes
5076
@self.router.post(f"/{self.provider_route_name}/api/chat")

0 commit comments

Comments
 (0)