MuntasirHossain commited on
Commit
34b3043
·
verified ·
1 Parent(s): b87c9e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -17
app.py CHANGED
@@ -32,13 +32,15 @@ def download_llms(llm_name):
32
  print("Download completed")
33
  else:
34
  print(f"Model download completed {response.status_code}")
 
35
 
36
  # define model pipeline with llama-cpp
37
  def initialize_llm(llm_model):
38
  model_path = ""
39
  if llm_model == llm_name:
40
- model_path = "model/Q4_K_M.gguf"
41
  download_llms(llm_model)
 
42
  llm = Llama(
43
  model_path=model_path,
44
  n_ctx=1024, # input text context length, 0 = from model
@@ -50,19 +52,19 @@ llm = initialize_llm(llm_name)
50
 
51
  # format prompt as per the ChatML template. The model was fine-tuned with this chat template
52
  def format_prompt(input_text, history):
53
- # system_prompt = """You are a helpful AI assistant. You are truthful in your response for real-world matters
54
- # but you are also creative for imaginative/fictional tasks."""
55
- system_prompt = """You are a large language model (LLM). Your primary role is to assist users by providing information, answering questions,
56
- and engaging in conversation. You are expected to be a subject matter expert across a wide range of topics. When asked about a particular subject,
57
- you should provide detailed, accurate, and up-to-date information.
58
- When a question involves reasoning or analysis, you should apply your reasoning and analytical skills to provide a well-thought-out response.
59
- You should strive to be truthful and accurate in your responses, especially when dealing with practical or real-life problems.
60
- However, you are not just a source of information. You are also capable of being creative and imaginative.
61
- When asked to engage in storytelling or to describe fictional characters and objects, you should use your creativity to generate engaging and imaginative content.
62
- Your goal is to understand the user's query and generate the best possible answer. You should adapt your response based on the nature of the query,
63
- whether it requires factual information, analytical reasoning, or creative imagination. You are a great all-rounder, capable of handling
64
- a wide variety of tasks and queries.
65
- """
66
  prompt = ""
67
  if history:
68
  for previous_prompt, response in history:
@@ -111,8 +113,8 @@ with gr.Blocks(theme=gr.themes.Default(primary_hue="sky")) as demo:
111
  clear_btn="Clear",
112
  # description="This AI agent is using the MuntasirHossain/Meta-Llama-3-8B-OpenOrca-GGUF model for text-generation.",
113
  # additional_inputs=additional_inputs,
114
- # examples=[["What is a large language model?"], ["What is the meaning of life?"], ["Write a short story about a fictional planet named 'Orca'."]]
115
- examples=[["Julie had 17 plums, she ate 12 of them, threw away 3 of them as they turned bad and bought 5 new. How many plums does she have now?"],
116
- ["Write a short story about a fictional planet named 'Orca'."]]
117
  )
118
  demo.queue().launch()
 
32
  print("Download completed")
33
  else:
34
  print(f"Model download completed {response.status_code}")
35
+ return llm_temp_file_path
36
 
37
  # define model pipeline with llama-cpp
38
  def initialize_llm(llm_model):
39
  model_path = ""
40
  if llm_model == llm_name:
41
+ # model_path = "model/Q4_K_M.gguf"
42
  download_llms(llm_model)
43
+ model_path=llm_temp_file_path
44
  llm = Llama(
45
  model_path=model_path,
46
  n_ctx=1024, # input text context length, 0 = from model
 
52
 
53
  # format prompt as per the ChatML template. The model was fine-tuned with this chat template
54
  def format_prompt(input_text, history):
55
+ system_prompt = """You are a helpful AI assistant. You are truthful in your response for real-world matters
56
+ but you are also creative for imaginative/fictional tasks."""
57
+ # system_prompt = """You are a large language model (LLM). Your primary role is to assist users by providing information, answering questions,
58
+ # and engaging in conversation. You are expected to be a subject matter expert across a wide range of topics. When asked about a particular subject,
59
+ # you should provide detailed, accurate, and up-to-date information.
60
+ # When a question involves reasoning or analysis, you should apply your reasoning and analytical skills to provide a well-thought-out response.
61
+ # You should strive to be truthful and accurate in your responses, especially when dealing with practical or real-life problems.
62
+ # However, you are not just a source of information. You are also capable of being creative and imaginative.
63
+ # When asked to engage in storytelling or to describe fictional characters and objects, you should use your creativity to generate engaging and imaginative content.
64
+ # Your goal is to understand the user's query and generate the best possible answer. You should adapt your response based on the nature of the query,
65
+ # whether it requires factual information, analytical reasoning, or creative imagination. You are a great all-rounder, capable of handling
66
+ # a wide variety of tasks and queries.
67
+ # """
68
  prompt = ""
69
  if history:
70
  for previous_prompt, response in history:
 
113
  clear_btn="Clear",
114
  # description="This AI agent is using the MuntasirHossain/Meta-Llama-3-8B-OpenOrca-GGUF model for text-generation.",
115
  # additional_inputs=additional_inputs,
116
+ examples=[["What is a large language model?"], ["What is the meaning of life?"], ["Write a short story about a fictional planet named 'Orca'."]]
117
+ # examples=[["Julie had 17 plums, she ate 12 of them, threw away 3 of them as they turned bad and bought 5 new. How many plums does she have now?"],
118
+ # ["Write a short story about a fictional planet named 'Orca'."]]
119
  )
120
  demo.queue().launch()