-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from dsba6010-llm-applications/neal-logan/back…
…end-add-fastapi Split main app to front-back subcomponents, added fastapi api to back
- Loading branch information
Showing
7 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from fastapi import FastAPI, HTTPException | ||
from pydantic import BaseModel | ||
|
||
# Initialize the FastAPI app | ||
app = FastAPI( | ||
title="MinuteMate Propmpt & Response API", | ||
description="A simple API that takes a text prompt uses ", | ||
version="1.0.0" | ||
|
||
) | ||
|
||
# Define the request schema | ||
class PromptRequest(BaseModel): | ||
prompt: str | ||
|
||
# Define the response schema | ||
class PromptResponse(BaseModel): | ||
response: str | ||
|
||
# Your Python processing logic | ||
def process_prompt(prompt: str) -> str: | ||
response = '' | ||
|
||
#Call whatever code we need to here | ||
|
||
return response | ||
|
||
# API endpoint | ||
@app.post("/process-prompt", response_model=PromptResponse) | ||
async def process_prompt_endpoint(request: PromptRequest): | ||
""" | ||
Process the prompt and return the response | ||
""" | ||
try: | ||
result = process_prompt(request.prompt) | ||
return PromptResponse(result=result) | ||
except Exception as e: | ||
raise HTTPException(status_code=500, detail=str(e)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Necessary for the API | ||
fastapi[standard] | ||
|
||
# Necessary for the API | ||
# Handles data validation, parsing, error handling, conversions, type hints | ||
pydantic | ||
|
||
# Necessary for web stuff | ||
uvicorn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM python:3.11-slim | ||
WORKDIR /App | ||
COPY . /App | ||
RUN python -m pip install -r requirements.txt | ||
EXPOSE 8000 | ||
CMD [" ", "start","--port","8002","--host","0.0.0.0"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.