alaselababatunde commited on
Commit
271148d
·
1 Parent(s): 88e3ef0
Files changed (1) hide show
  1. main.py +10 -5
main.py CHANGED
@@ -40,16 +40,17 @@ app = FastAPI(title="Tech Disciples AI (LangChain Conversational)", version="3.0
40
  try:
41
  logger.info(f"🚀 Loading model: {MODEL_NAME}")
42
 
 
43
  hf_pipeline = pipeline(
44
  "text2text-generation",
45
  model=MODEL_NAME,
46
  device=DEVICE,
47
- max_new_tokens=256,
48
- temperature=0.3,
49
- do_sample=True,
50
- top_p=0.9
51
  )
52
 
 
53
  llm = HuggingFacePipeline(pipeline=hf_pipeline)
54
  logger.info("✅ Model loaded successfully.")
55
 
@@ -67,7 +68,10 @@ memory = ConversationBufferMemory(memory_key="conversation_history")
67
  # ===============================================
68
  prompt_template = """
69
  You are Tech Disciples AI — a spiritually aware, intelligent, and kind conversational assistant.
70
- You offer thoughtful, biblical, and insightful answers with grace, empathy, and calm intelligence.
 
 
 
71
 
72
  Conversation so far:
73
  {conversation_history}
@@ -76,6 +80,7 @@ User: {query}
76
  Tech Disciples AI:
77
  """
78
 
 
79
  prompt = PromptTemplate(
80
  template=prompt_template,
81
  input_variables=["conversation_history", "query"]
 
40
  try:
41
  logger.info(f"🚀 Loading model: {MODEL_NAME}")
42
 
43
+
44
  hf_pipeline = pipeline(
45
  "text2text-generation",
46
  model=MODEL_NAME,
47
  device=DEVICE,
48
+ max_new_tokens=512,
49
+ temperature=0.0, # deterministic
50
+ do_sample=False # reduce hedging
 
51
  )
52
 
53
+
54
  llm = HuggingFacePipeline(pipeline=hf_pipeline)
55
  logger.info("✅ Model loaded successfully.")
56
 
 
68
  # ===============================================
69
  prompt_template = """
70
  You are Tech Disciples AI — a spiritually aware, intelligent, and kind conversational assistant.
71
+ You give direct, thoughtful, and biblical answers with grace and empathy.
72
+
73
+ Always answer the user question directly, if it relates to Christianity or the Bible.
74
+ If the question is not related to Christianity or the Bible, politely inform the user that you only respond to questions on Christianity and the Bible.
75
 
76
  Conversation so far:
77
  {conversation_history}
 
80
  Tech Disciples AI:
81
  """
82
 
83
+
84
  prompt = PromptTemplate(
85
  template=prompt_template,
86
  input_variables=["conversation_history", "query"]