shengwei62 commited on
Commit
be2fbc5
1 Parent(s): 656302b

Delete api/app/main.py

Browse files
Files changed (1) hide show
  1. api/app/main.py +0 -56
api/app/main.py DELETED
@@ -1,56 +0,0 @@
1
- from fastapi import FastAPI, Form
2
- from fastapi.middleware.cors import CORSMiddleware
3
- from fastapi.staticfiles import StaticFiles
4
- from fastapi.responses import HTMLResponse
5
- from .ai.chatbot import gpt_chatbot, llama_chatbot
6
-
7
- isProduction = False
8
-
9
- origins = ["*"]
10
-
11
- if isProduction:
12
- app = FastAPI(
13
- title="LLM API Endpoints",
14
- docs_url=None, # Disable docs (Swagger UI)
15
- redoc_url=None, # Disable redoc
16
- )
17
- #app.mount("/static", StaticFiles(directory="static"), name="static")
18
- else:
19
- app = FastAPI(title="LLM API Endpoints")
20
- #app.mount("/static", StaticFiles(directory="static"), name="static")
21
-
22
- app.add_middleware(
23
- CORSMiddleware,
24
- allow_origins=origins,
25
- allow_credentials=True,
26
- allow_methods=["POST", "GET", "PUT", "DELETE"],
27
- allow_headers=["*"],
28
- )
29
-
30
-
31
- # Create a homepage route
32
- @app.get("/")
33
- async def index():
34
- return {"server ok": True}
35
-
36
-
37
- @app.post("/api/chat/gpt3", tags=["OpenAI GPT-3"])
38
- async def gpt_chat(user_request: str = Form(...)):
39
- """
40
- Chat with LLM Backend - GPT-3
41
- """
42
- # Get the text content in the user request
43
- result = gpt_chatbot(user_request=user_request)
44
-
45
- return {"result": result}
46
-
47
-
48
- @app.post("/api/chat/llama", tags=["Llama 2 7B Chat"])
49
- async def llama_chat(user_request: str = Form(...)):
50
- """
51
- Chat with LLM Backend - Llama 2 7b Chat
52
- """
53
- # Get the text content in the user request
54
- result = llama_chatbot(user_request=user_request)
55
-
56
- return {"result": result}