desert commited on
Commit
ded9e09
·
1 Parent(s): def541d

init inference

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -21,19 +21,23 @@ def chat_with_model(user_input, chat_history):
21
  :param chat_history: List of [user_message, ai_response] pairs
22
  :return: Updated chat history
23
  """
24
- # Combine chat history into a single prompt
25
  prompt = ""
26
  for user, ai in chat_history:
27
  prompt += f"User: {user}\nAI: {ai}\n"
28
- prompt += f"User: {user_input}\nAI:"
29
 
30
  # Generate response from the model
31
- response = llm(prompt)["choices"][0]["text"].strip()
32
 
33
- # Update chat history as a list of tuples
 
 
 
34
  chat_history.append((user_input, response))
35
  return chat_history, chat_history
36
 
 
37
  # Gradio UI
38
  with gr.Blocks() as demo:
39
  gr.Markdown("# 🦙 LLaMA GGUF Chatbot")
 
21
  :param chat_history: List of [user_message, ai_response] pairs
22
  :return: Updated chat history
23
  """
24
+ # Construct the prompt from chat history
25
  prompt = ""
26
  for user, ai in chat_history:
27
  prompt += f"User: {user}\nAI: {ai}\n"
28
+ prompt += f"User: {user_input}\nAI:" # Add the latest user input
29
 
30
  # Generate response from the model
31
+ raw_response = llm(prompt)["choices"][0]["text"].strip()
32
 
33
+ # Clean the response (remove extra tags, if any)
34
+ response = raw_response.split("User:")[0].strip()
35
+
36
+ # Update chat history with the new turn
37
  chat_history.append((user_input, response))
38
  return chat_history, chat_history
39
 
40
+
41
  # Gradio UI
42
  with gr.Blocks() as demo:
43
  gr.Markdown("# 🦙 LLaMA GGUF Chatbot")