Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,7 @@ from transformers import pipeline
|
|
| 19 |
import os
|
| 20 |
import transformers
|
| 21 |
import torch
|
|
|
|
| 22 |
# from langchain_retrieval import BaseRetrieverChain
|
| 23 |
# from dotenv import load_dotenv
|
| 24 |
|
|
@@ -100,8 +101,8 @@ def get_conversational_rag_chain(retriever_chain,llm):
|
|
| 100 |
|
| 101 |
def safe_llm(input_str: str) -> str:
|
| 102 |
if isinstance(input_str, langchain_core.prompts.chat.ChatPromptValue):
|
| 103 |
-
|
| 104 |
-
input_str = input_str.to_messages()
|
| 105 |
|
| 106 |
# Call the original llm, which should now work correctly
|
| 107 |
return llm(input_str)
|
|
@@ -144,7 +145,15 @@ def get_response(user_input):
|
|
| 144 |
# task="text2text-generation",
|
| 145 |
# # model_kwargs={"temperature": 0.2},
|
| 146 |
# )
|
| 147 |
-
llm = pipeline(task="conversational", model="facebook/blenderbot-400M-distill")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
# llm = HuggingFacePipeline.from_model_id(
|
| 150 |
# model_id="lmsys/fastchat-t5-3b-v1.0",
|
|
|
|
| 19 |
import os
|
| 20 |
import transformers
|
| 21 |
import torch
|
| 22 |
+
from langchain_community.llms import LlamaCpp
|
| 23 |
# from langchain_retrieval import BaseRetrieverChain
|
| 24 |
# from dotenv import load_dotenv
|
| 25 |
|
|
|
|
| 101 |
|
| 102 |
def safe_llm(input_str: str) -> str:
|
| 103 |
if isinstance(input_str, langchain_core.prompts.chat.ChatPromptValue):
|
| 104 |
+
input_str = str(input_str)
|
| 105 |
+
# input_str = input_str.to_messages()
|
| 106 |
|
| 107 |
# Call the original llm, which should now work correctly
|
| 108 |
return llm(input_str)
|
|
|
|
| 145 |
# task="text2text-generation",
|
| 146 |
# # model_kwargs={"temperature": 0.2},
|
| 147 |
# )
|
| 148 |
+
# llm = pipeline(task="conversational", model="facebook/blenderbot-400M-distill")
|
| 149 |
+
llm = LlamaCpp(
|
| 150 |
+
model_path="TheBloke/OpenOrca-Platypus2-13B-GGUF",
|
| 151 |
+
temperature=0.75,
|
| 152 |
+
max_tokens=2000,
|
| 153 |
+
top_p=1,
|
| 154 |
+
# callback_manager=callback_manager,
|
| 155 |
+
verbose=True, # Verbose is required to pass to the callback manager
|
| 156 |
+
)
|
| 157 |
|
| 158 |
# llm = HuggingFacePipeline.from_model_id(
|
| 159 |
# model_id="lmsys/fastchat-t5-3b-v1.0",
|