Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit cc77a57

Browse files
committed
start adding lm_studio
1 parent c8bc5ec commit cc77a57

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/codegate/providers/ollama/completion_handler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ async def ollama_stream_generator(
1818
try:
1919
async for chunk in stream:
2020
try:
21+
yield f"{chunk.model_dump_json()}\n\n"
2122
# TODO We should wire in the client info so we can respond with
2223
# the correct format and start to handle multiple clients
2324
# in a more robust way.

src/codegate/providers/ollama/provider.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ async def create_completion(request: Request):
8787

8888
is_fim_request = self._is_fim_request(request, data)
8989
try:
90-
print("i create completion with data", data)
9190
stream = await self.complete(data, api_key=None, is_fim_request=is_fim_request)
9291
except httpx.ConnectError as e:
9392
logger = structlog.get_logger("codegate")
@@ -103,6 +102,4 @@ async def create_completion(request: Request):
103102
else:
104103
# just continue raising the exception
105104
raise e
106-
print("result is")
107-
print(self._completion_handler.create_response(stream))
108105
return self._completion_handler.create_response(stream)

src/codegate/providers/openai/provider.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22

3+
import httpx
34
import structlog
45
from fastapi import Header, HTTPException, Request
56

@@ -35,6 +36,7 @@ def _setup_routes(self):
3536

3637
@self.router.post(f"/{self.provider_route_name}/chat/completions")
3738
@self.router.post(f"/{self.provider_route_name}/completions")
39+
@self.router.post(f"/{self.provider_route_name}/v1/chat/completions")
3840
async def create_completion(
3941
request: Request,
4042
authorization: str = Header(..., description="Bearer token"),
@@ -45,7 +47,6 @@ async def create_completion(
4547
api_key = authorization.split(" ")[1]
4648
body = await request.body()
4749
data = json.loads(body)
48-
4950
is_fim_request = self._is_fim_request(request, data)
5051
try:
5152
stream = await self.complete(data, api_key, is_fim_request=is_fim_request)

0 commit comments

Comments
 (0)