This repository was archived by the owner on Jun 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathserver.py
More file actions
68 lines (56 loc) · 2.35 KB
/
server.py
File metadata and controls
68 lines (56 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from typing import List
from fastapi import APIRouter, FastAPI
from codegate import __description__, __version__
from codegate.config import Config
from codegate.pipeline.base import PipelineStep, SequentialPipelineProcessor
from codegate.pipeline.codegate_system_prompt.codegate import CodegateSystemPrompt
from codegate.pipeline.extract_snippets.extract_snippets import CodeSnippetExtractor
from codegate.pipeline.version.version import CodegateVersion
from codegate.providers.anthropic.provider import AnthropicProvider
from codegate.providers.llamacpp.provider import LlamaCppProvider
from codegate.providers.openai.provider import OpenAIProvider
from codegate.providers.registry import ProviderRegistry
from codegate.providers.vllm.provider import VLLMProvider
def init_app() -> FastAPI:
app = FastAPI(
title="CodeGate",
description=__description__,
version=__version__,
)
steps: List[PipelineStep] = [
CodegateVersion(),
CodeSnippetExtractor(),
CodegateSystemPrompt(Config.get_config().prompts.codegate_chat),
# CodegateSecrets(),
]
# Leaving the pipeline empty for now
fim_steps: List[PipelineStep] = []
pipeline = SequentialPipelineProcessor(steps)
fim_pipeline = SequentialPipelineProcessor(fim_steps)
# Create provider registry
registry = ProviderRegistry(app)
# Initialize SignaturesFinder
# CodegateSignatures.initialize("signatures.yaml")
# Register all known providers
registry.add_provider(
"openai", OpenAIProvider(pipeline_processor=pipeline, fim_pipeline_processor=fim_pipeline)
)
registry.add_provider(
"anthropic",
AnthropicProvider(pipeline_processor=pipeline, fim_pipeline_processor=fim_pipeline),
)
registry.add_provider(
"llamacpp",
LlamaCppProvider(pipeline_processor=pipeline, fim_pipeline_processor=fim_pipeline),
)
registry.add_provider(
"vllm", VLLMProvider(pipeline_processor=pipeline, fim_pipeline_processor=fim_pipeline)
)
# Create and add system routes
system_router = APIRouter(tags=["System"]) # Tags group endpoints in the docs
@system_router.get("/health")
async def health_check():
return {"status": "healthy"}
# Include the router in the app - this exposes the health check endpoint
app.include_router(system_router)
return app