Akjava commited on
Commit
4d69435
·
verified ·
1 Parent(s): 58e6047

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -172,9 +172,7 @@ class LlamaCppModel(Model):
172
  **kwargs,
173
  ) -> ChatMessage:
174
 
175
- """
176
- Generates a response from the llama.cpp model and integrates tool usage *only if tools are provided*.
177
- """
178
 
179
  from llama_cpp import LlamaGrammar
180
  try:
@@ -183,7 +181,6 @@ class LlamaCppModel(Model):
183
  stop_sequences=stop_sequences,
184
  grammar=grammar,
185
  tools_to_call_from=tools_to_call_from,
186
- #flatten_messages_as_text=True,
187
  **kwargs
188
  )
189
 
@@ -201,7 +198,7 @@ class LlamaCppModel(Model):
201
  or 1024
202
  )
203
 
204
- provider = LlamaCppPythonProvider(self.llm)
205
  system_message= completion_kwargs["messages"][0]["content"]
206
  message= completion_kwargs["messages"].pop()["content"]
207
 
@@ -225,7 +222,7 @@ class LlamaCppModel(Model):
225
  settings.repeat_penalty = repeat_penalty
226
  settings.stream = False
227
 
228
- print(len(completion_kwargs["messages"]))
229
  messages = BasicChatHistory()
230
  for from_message in completion_kwargs["messages"]:
231
  if from_message["role"] is MessageRole.USER:
@@ -235,7 +232,7 @@ class LlamaCppModel(Model):
235
  else:
236
  history_message = {"role": MessageRole.ASSISTANT, "content": from_message["content"]}
237
  messages.add_message(from_message)
238
- print("<history>")
239
  stream = agent.get_chat_response(
240
  message,
241
  llm_sampling_settings=settings,
 
172
  **kwargs,
173
  ) -> ChatMessage:
174
 
175
+
 
 
176
 
177
  from llama_cpp import LlamaGrammar
178
  try:
 
181
  stop_sequences=stop_sequences,
182
  grammar=grammar,
183
  tools_to_call_from=tools_to_call_from,
 
184
  **kwargs
185
  )
186
 
 
198
  or 1024
199
  )
200
 
201
+ provider = LlamaCppPythonProvider(self.llm)
202
  system_message= completion_kwargs["messages"][0]["content"]
203
  message= completion_kwargs["messages"].pop()["content"]
204
 
 
222
  settings.repeat_penalty = repeat_penalty
223
  settings.stream = False
224
 
225
+
226
  messages = BasicChatHistory()
227
  for from_message in completion_kwargs["messages"]:
228
  if from_message["role"] is MessageRole.USER:
 
232
  else:
233
  history_message = {"role": MessageRole.ASSISTANT, "content": from_message["content"]}
234
  messages.add_message(from_message)
235
+
236
  stream = agent.get_chat_response(
237
  message,
238
  llm_sampling_settings=settings,