vislupus commited on
Commit
ae13704
·
verified ·
1 Parent(s): b665fc9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -30,9 +30,6 @@ llm = Llama(model_path=model_path)
30
  print("Model loaded successfully!")
31
 
32
  def generate_response(message, history, temperature=0.7, top_p=1.0, max_tokens=256):
33
- """
34
- Generate a response based on the user's message and the conversation history.
35
- """
36
  try:
37
  conversation = ""
38
  for msg in history:
@@ -40,10 +37,10 @@ def generate_response(message, history, temperature=0.7, top_p=1.0, max_tokens=2
40
  conversation += f"<start_of_turn>{role}\n{content}\n<end_of_turn>"
41
 
42
  conversation += f"<start_of_turn>user\n{message}\n<end_of_turn>"
43
-
44
  response = llm(conversation, max_tokens=max_tokens, temperature=temperature, top_p=top_p)
45
  return response["choices"][0]["text"].strip()
46
-
47
  except Exception as e:
48
  return f"Error generating response: {str(e)}"
49
 
 
30
  print("Model loaded successfully!")
31
 
32
  def generate_response(message, history, temperature=0.7, top_p=1.0, max_tokens=256):
 
 
 
33
  try:
34
  conversation = ""
35
  for msg in history:
 
37
  conversation += f"<start_of_turn>{role}\n{content}\n<end_of_turn>"
38
 
39
  conversation += f"<start_of_turn>user\n{message}\n<end_of_turn>"
40
+
41
  response = llm(conversation, max_tokens=max_tokens, temperature=temperature, top_p=top_p)
42
  return response["choices"][0]["text"].strip()
43
+
44
  except Exception as e:
45
  return f"Error generating response: {str(e)}"
46