Skip to content

Commit

Permalink
Merge pull request #38 from dsba6010-llm-applications/neal-logan/back…
Browse files Browse the repository at this point in the history
…end-add-fastapi

Split main app to front-back subcomponents, added fastapi api to back
  • Loading branch information
iam-yashpradhan authored Nov 17, 2024
2 parents ae1b400 + 85a6452 commit 6acf64e
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 0 deletions.
File renamed without changes.
38 changes: 38 additions & 0 deletions MinuteMate/back/main.py
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))
9 changes: 9 additions & 0 deletions MinuteMate/back/requirements.txt
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
6 changes: 6 additions & 0 deletions MinuteMate/front/Dockerfile
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.

0 comments on commit 6acf64e

Please sign in to comment.