AminFaraji commited on
Commit
87995aa
·
verified ·
1 Parent(s): 078dec5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -32
app.py CHANGED
@@ -127,25 +127,6 @@ AI:
127
 
128
 
129
 
130
- stop_tokens = [["Human", ":"], ["AI", ":"]]
131
- stopping_criteria = StoppingCriteriaList(
132
- [StopGenerationCriteria(stop_tokens, tokenizer, model.device)]
133
- )
134
-
135
-
136
-
137
- class CleanupOutputParser(BaseOutputParser):
138
- def parse(self, text: str) -> str:
139
- user_pattern = r"\nUser"
140
- text = re.sub(user_pattern, "", text)
141
- human_pattern = r"\nHuman:"
142
- text = re.sub(human_pattern, "", text)
143
- ai_pattern = r"\nAI:"
144
- return re.sub(ai_pattern, "", text).strip()
145
-
146
- @property
147
- def _type(self) -> str:
148
- return "output_parser"
149
 
150
 
151
  template = """
@@ -156,19 +137,6 @@ Current conversation:
156
 
157
  Human: {input}
158
  AI:""".strip()
159
- prompt = PromptTemplate(input_variables=["history", "input"], template=template)
160
-
161
- memory = ConversationBufferWindowMemory(
162
- memory_key="history", k=6, return_only_outputs=True
163
- )
164
-
165
- chain = ConversationChain(
166
- llm=llm,
167
- memory=memory,
168
- prompt=prompt,
169
- output_parser=CleanupOutputParser(),
170
- verbose=True,
171
- )
172
 
173
 
174
  def get_llama_response(message: str, history: list) -> str:
 
127
 
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
 
131
 
132
  template = """
 
137
 
138
  Human: {input}
139
  AI:""".strip()
 
 
 
 
 
 
 
 
 
 
 
 
 
140
 
141
 
142
  def get_llama_response(message: str, history: list) -> str: