File tree 1 file changed +26
-0
lines changed
src/codegate/providers/ollama
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,32 @@ def _setup_routes(self):
45
45
"""
46
46
Sets up Ollama API routes.
47
47
"""
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 ()
48
74
49
75
# Native Ollama API routes
50
76
@self .router .post (f"/{ self .provider_route_name } /api/chat" )
You can’t perform that action at this time.
0 commit comments