alaselababatunde commited on
Commit
a67fd6f
·
1 Parent(s): 21cb694
Files changed (1) hide show
  1. main.py +12 -2
main.py CHANGED
@@ -3,6 +3,7 @@
3
  # =====================================================
4
 
5
  from fastapi import FastAPI, HTTPException, Header
 
6
  from pydantic import BaseModel
7
  import torch
8
  import logging
@@ -34,6 +35,15 @@ logger = logging.getLogger("TechDisciplesAI")
34
  # =====================================================
35
  app = FastAPI(title="Tech Disciples AI", version="3.1")
36
 
 
 
 
 
 
 
 
 
 
37
  # =====================================================
38
  # MODEL LOADING FUNCTION
39
  # =====================================================
@@ -85,7 +95,7 @@ memory = ConversationBufferMemory(memory_key="conversation_history")
85
  prompt_template = """
86
  You are Tech Disciples AI — a warm, spiritual, and knowledgeable conversational AI built
87
  to give Biblical guidance and Christian-based reflections. You speak with empathy, wisdom,
88
- and natural tone — never robotic. Always connect your points to scripture or Christian principles
89
  when relevant.
90
 
91
  Conversation so far:
@@ -114,7 +124,7 @@ class QueryInput(BaseModel):
114
  # =====================================================
115
  @app.get("/")
116
  async def root():
117
- return {"message": "✅ Tech Disciples AI is online."}
118
 
119
  @app.post("/ai-chat")
120
  async def ai_chat(data: QueryInput, x_api_key: str = Header(None)):
 
3
  # =====================================================
4
 
5
  from fastapi import FastAPI, HTTPException, Header
6
+ from fastapi.middleware.cors import CORSMiddleware
7
  from pydantic import BaseModel
8
  import torch
9
  import logging
 
35
  # =====================================================
36
  app = FastAPI(title="Tech Disciples AI", version="3.1")
37
 
38
+ # ✅ Enable CORS (allow all origins for now; can restrict later)
39
+ app.add_middleware(
40
+ CORSMiddleware,
41
+ allow_origins=["*"], # 🔒 Change this to your frontend URL when known
42
+ allow_credentials=True,
43
+ allow_methods=["*"],
44
+ allow_headers=["*"],
45
+ )
46
+
47
  # =====================================================
48
  # MODEL LOADING FUNCTION
49
  # =====================================================
 
95
  prompt_template = """
96
  You are Tech Disciples AI — a warm, spiritual, and knowledgeable conversational AI built
97
  to give Biblical guidance and Christian-based reflections. You speak with empathy, wisdom,
98
+ and a natural tone — never robotic. Always connect your points to scripture or Christian principles
99
  when relevant.
100
 
101
  Conversation so far:
 
124
  # =====================================================
125
  @app.get("/")
126
  async def root():
127
+ return {"message": "✅ Tech Disciples AI is online and ready."}
128
 
129
  @app.post("/ai-chat")
130
  async def ai_chat(data: QueryInput, x_api_key: str = Header(None)):