Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -19,13 +19,17 @@ import chainlit as cl
|
|
19 |
from langchain import hub
|
20 |
from langchain.chains import LLMChain, APIChain
|
21 |
from langchain_core.prompts import PromptTemplate
|
|
|
|
|
22 |
from langchain_community.llms import HuggingFaceHub
|
|
|
23 |
from langchain_huggingface import HuggingFaceEndpoint
|
24 |
-
from
|
25 |
|
26 |
-
logging.basicConfig(level=logging.DEBUG)
|
27 |
|
28 |
-
|
|
|
29 |
#BOOKING_ID = re.compile(r'\b[A-Z]{6}\d{6}\b')
|
30 |
BOOKING_KEYWORDS = [
|
31 |
"booking",
|
@@ -91,14 +95,27 @@ api_response_prompt = PromptTemplate(
|
|
91 |
@cl.on_chat_start
|
92 |
def setup_multiple_chains():
|
93 |
|
94 |
-
llm =
|
95 |
repo_id="google/gemma-2-2b-it", #"norallm/normistral-7b-warm-instruct",
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
)
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
conversation_memory = ConversationBufferMemory(memory_key="chat_history",
|
103 |
max_len=200,
|
104 |
return_messages=True,
|
|
|
19 |
from langchain import hub
|
20 |
from langchain.chains import LLMChain, APIChain
|
21 |
from langchain_core.prompts import PromptTemplate
|
22 |
+
from langchain.memory.buffer import ConversationBufferMemory
|
23 |
+
|
24 |
from langchain_community.llms import HuggingFaceHub
|
25 |
+
from langchain_huggingface import HuggingFacePipeline
|
26 |
from langchain_huggingface import HuggingFaceEndpoint
|
27 |
+
from langchain_core.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
|
28 |
|
29 |
+
#logging.basicConfig(level=logging.DEBUG)
|
30 |
|
31 |
+
|
32 |
+
#HF_INFERENCE_ENDPOINT =
|
33 |
#BOOKING_ID = re.compile(r'\b[A-Z]{6}\d{6}\b')
|
34 |
BOOKING_KEYWORDS = [
|
35 |
"booking",
|
|
|
95 |
@cl.on_chat_start
|
96 |
def setup_multiple_chains():
|
97 |
|
98 |
+
llm = HuggingFaceEndpoint(
|
99 |
repo_id="google/gemma-2-2b-it", #"norallm/normistral-7b-warm-instruct",
|
100 |
+
#endpoint_url="http://localhost:8010/",
|
101 |
+
model="gemma-2-2b-it",
|
102 |
+
max_new_tokens=512,
|
103 |
+
top_k=10,
|
104 |
+
top_p=0.95,
|
105 |
+
typical_p=0.95,
|
106 |
+
temperature=0.7,
|
107 |
+
repetition_penalty=1.03,
|
108 |
+
huggingfacehub_api_token=os.environ.get("HUGGINGFACEHUB_API_TOKEN"),
|
109 |
+
task="text-generation"
|
110 |
)
|
111 |
|
112 |
+
|
113 |
+
#llm = HuggingFacePipeline.from_model_id(
|
114 |
+
#model_id="normistral-7b-warm-instruct",
|
115 |
+
#task="text-generation",
|
116 |
+
#pipeline_kwargs={"max_new_tokens": 10},
|
117 |
+
#)
|
118 |
+
|
119 |
conversation_memory = ConversationBufferMemory(memory_key="chat_history",
|
120 |
max_len=200,
|
121 |
return_messages=True,
|