-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
63 lines (45 loc) · 1.28 KB
/
main.py
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
from fastapi import FastAPI, Request, Depends, HTTPException
from fastapi.responses import JSONResponse, FileResponse
from fastapi.staticfiles import StaticFiles
from fastapi.middleware.cors import CORSMiddleware
import uvicorn
from pydantic import BaseModel
import os
import threading
from src.Configuration.config import Config
from src.LoggingService.logger import Logger
from src.ProjectManagement.project import ProjectManager
from src.StateManagement.state import AgentState
from src.agents.central_agent import Agent
from src.ModelInference.llm import LLM
import tiktoken
# Initialize FastAPI
app = FastAPI()
# CORS middleware
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# Pydantic models for request bodies
class ProjectName(BaseModel):
project_name: str
class MessageData(BaseModel):
project_name: str
message: str
class CodeData(BaseModel):
project_name: str
code: str
class PromptData(BaseModel):
prompt: str
# Dependency injections
def get_logger():
return Logger()
def get_manager():
return ProjectManager()
def get_config():
return Config()
TIKTOKEN_ENC = tiktoken.get_encoding("cl100k_base")
os.environ["TOKENIZERS_PARALLELISM"] = "false"