import fastapi | |
import json | |
import uvicorn | |
from fastapi import HTTPException | |
from fastapi.responses import HTMLResponse | |
from fastapi.middleware.cors import CORSMiddleware | |
from sse_starlette.sse import EventSourceResponse | |
from starlette.responses import StreamingResponse | |
from pydantic import BaseModel | |
from typing import List, Dict, Any, Generator, Optional | |
from server import client | |
from chromadb.api.types import ( | |
Documents, | |
Embeddings, | |
EmbeddingFunction, | |
IDs, | |
Include, | |
Metadatas, | |
Where, | |
WhereDocument, | |
GetResult, | |
QueryResult, | |
CollectionMetadata, | |
) | |
app = fastapi.FastAPI(title="ChromaDB") | |
app.add_middleware( | |
CORSMiddleware, | |
allow_origins=["*"], | |
allow_credentials=True, | |
allow_methods=["*"], | |
allow_headers=["*"], | |
) | |
api_base="/api/v1" | |
bkend=client() | |
def heartbeat(): | |
print("Received heartbeat request") | |
return bkend.heartbeat() | |
def list_collection(): | |
print("Received list_collection request") | |
return bkend.list_collections() | |
if __name__ == "__main__": | |
uvicorn.run(app, host="0.0.0.0", port=8000) | |