Nada commited on
Commit ·
910249b
1
Parent(s): db641fe
not starting
Browse files- chatbot.py +1 -14
chatbot.py
CHANGED
|
@@ -310,12 +310,6 @@ Response:"""
|
|
| 310 |
)
|
| 311 |
|
| 312 |
# Create the conversation chain
|
| 313 |
-
# LLMChain combines the language model, prompt template, and memory
|
| 314 |
-
# This creates a conversational agent that can:
|
| 315 |
-
# - Generate responses using the LLM
|
| 316 |
-
# - Use the prompt template for structured input
|
| 317 |
-
# - Maintain conversation history in memory
|
| 318 |
-
# - verbose=False: Disables detailed logging of chain operations
|
| 319 |
self.conversation = LLMChain(
|
| 320 |
llm=self.llm,
|
| 321 |
prompt=self.prompt_template,
|
|
@@ -324,16 +318,12 @@ Response:"""
|
|
| 324 |
)
|
| 325 |
|
| 326 |
# Setup embeddings for vector search
|
| 327 |
-
# HuggingFaceEmbeddings converts text to numerical vectors for similarity search
|
| 328 |
-
# all-MiniLM-L6-v2 is a lightweight but effective sentence embedding model
|
| 329 |
-
# These embeddings enable semantic search of past conversations and guidelines
|
| 330 |
self.embeddings = HuggingFaceEmbeddings(
|
| 331 |
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
| 332 |
)
|
| 333 |
|
| 334 |
# Setup vector database for retrieving relevant past conversations
|
| 335 |
-
|
| 336 |
-
# This enables semantic search to find relevant context for each response
|
| 337 |
if therapy_guidelines_path and os.path.exists(therapy_guidelines_path):
|
| 338 |
self.setup_vector_db(therapy_guidelines_path)
|
| 339 |
else:
|
|
@@ -446,9 +436,6 @@ Response:"""
|
|
| 446 |
)
|
| 447 |
|
| 448 |
# Create LangChain wrapper
|
| 449 |
-
# HuggingFacePipeline wraps the HuggingFace pipeline for use with LangChain
|
| 450 |
-
# This enables the pipeline to work seamlessly with LangChain components
|
| 451 |
-
# like chains, memory, and prompts
|
| 452 |
llm = HuggingFacePipeline(pipeline=text_generator)
|
| 453 |
|
| 454 |
return model, tokenizer, llm
|
|
|
|
| 310 |
)
|
| 311 |
|
| 312 |
# Create the conversation chain
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 313 |
self.conversation = LLMChain(
|
| 314 |
llm=self.llm,
|
| 315 |
prompt=self.prompt_template,
|
|
|
|
| 318 |
)
|
| 319 |
|
| 320 |
# Setup embeddings for vector search
|
|
|
|
|
|
|
|
|
|
| 321 |
self.embeddings = HuggingFaceEmbeddings(
|
| 322 |
model_name="sentence-transformers/all-MiniLM-L6-v2"
|
| 323 |
)
|
| 324 |
|
| 325 |
# Setup vector database for retrieving relevant past conversations
|
| 326 |
+
|
|
|
|
| 327 |
if therapy_guidelines_path and os.path.exists(therapy_guidelines_path):
|
| 328 |
self.setup_vector_db(therapy_guidelines_path)
|
| 329 |
else:
|
|
|
|
| 436 |
)
|
| 437 |
|
| 438 |
# Create LangChain wrapper
|
|
|
|
|
|
|
|
|
|
| 439 |
llm = HuggingFacePipeline(pipeline=text_generator)
|
| 440 |
|
| 441 |
return model, tokenizer, llm
|