Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cline Support #463

Merged
merged 9 commits into from
Jan 23, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix ollama for cline
yrobla committed Jan 23, 2025
commit 3914737ffc7c10958881936e04f5224b889a1e08
2 changes: 1 addition & 1 deletion src/codegate/providers/completion/base.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ async def execute_completion(
api_key: Optional[str],
stream: bool = False, # TODO: remove this param?
is_fim_request: bool = False,
is_cline_client: bool = False,
base_tool: Optional[str] = "",
) -> Union[ModelResponse, AsyncIterator[ModelResponse]]:
"""Execute the completion request"""
pass
10 changes: 5 additions & 5 deletions src/codegate/providers/ollama/completion_handler.py
Original file line number Diff line number Diff line change
@@ -63,15 +63,13 @@ async def ollama_stream_generator(
if field in chunk_dict:
response[field] = chunk_dict[field]

print("in cline")
print(json.dumps(response))
yield f"data: {json.dumps(response)}\n"
yield f"\ndata: {json.dumps(response)}\n"
except Exception as e:
logger.error(f"Error in stream generator: {str(e)}")
yield f"data: {json.dumps({'error': str(e), 'type': 'error', 'choices': []})}\n"
yield f"\ndata: {json.dumps({'error': str(e), 'type': 'error', 'choices': []})}\n"
except Exception as e:
logger.error(f"Stream error: {str(e)}")
yield f"data: {json.dumps({'error': str(e), 'type': 'error', 'choices': []})}\n"
yield f"\ndata: {json.dumps({'error': str(e), 'type': 'error', 'choices': []})}\n"


class OllamaShim(BaseCompletionHandler):
@@ -115,7 +113,9 @@ def _create_streaming_response(self, stream: AsyncIterator[ChatResponse]) -> Str
headers={
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Transfer-Encoding": "chunked",
},
status_code=200,
)

def _create_json_response(