abdibrahem commited on
Commit
98620f5
·
1 Parent(s): 0890717

Update the function name of processing voice, add cors to the project

Browse files
Files changed (1) hide show
  1. main.py +10 -2
main.py CHANGED
@@ -1076,6 +1076,8 @@ class HealthcareChatbot:
1076
  from fastapi import FastAPI, HTTPException, UploadFile, File
1077
  from pydantic import BaseModel
1078
  from typing import Dict, Any, Optional
 
 
1079
 
1080
 
1081
  app = FastAPI(
@@ -1083,7 +1085,13 @@ app = FastAPI(
1083
  description="An AI-powered healthcare assistant that handles appointment booking and queries",
1084
  version="1.0.0"
1085
  )
1086
-
 
 
 
 
 
 
1087
  # Initialize the AI agent
1088
  agent = HealthcareChatbot()
1089
 
@@ -1103,7 +1111,7 @@ async def process_query(request: QueryRequest):
1103
  raise HTTPException(status_code=500, detail=str(e))
1104
 
1105
  @app.post("/voice-text")
1106
- async def process_query(file: UploadFile = File(...)):
1107
  """
1108
  Process a user voice and return a response
1109
  """
 
1076
  from fastapi import FastAPI, HTTPException, UploadFile, File
1077
  from pydantic import BaseModel
1078
  from typing import Dict, Any, Optional
1079
+ from fastapi.middleware.cors import CORSMiddleware
1080
+
1081
 
1082
 
1083
  app = FastAPI(
 
1085
  description="An AI-powered healthcare assistant that handles appointment booking and queries",
1086
  version="1.0.0"
1087
  )
1088
+ app.add_middleware(
1089
+ CORSMiddleware,
1090
+ allow_origins=["*"],
1091
+ allow_credentials=True,
1092
+ allow_methods=["*"],
1093
+ allow_headers=["*"],
1094
+ )
1095
  # Initialize the AI agent
1096
  agent = HealthcareChatbot()
1097
 
 
1111
  raise HTTPException(status_code=500, detail=str(e))
1112
 
1113
  @app.post("/voice-text")
1114
+ async def process_voice(file: UploadFile = File(...)):
1115
  """
1116
  Process a user voice and return a response
1117
  """