dominguezdaniel commited on
Commit
d62bfcf
·
verified ·
1 Parent(s): 10e4a04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -1,18 +1,26 @@
1
  from llama_cpp import Llama
2
  import gradio as gr
3
 
4
- # Load the model
5
- llm = Llama(model_path="mistral-7b-instruct-v0.1.Q4_K_M.gguf", n_ctx=2048)
 
 
 
 
 
6
 
7
  def generate_description(business_name):
8
- prompt = f"""<s>[INST] Write a commercial and SEO-optimized Google My Business description for a business called "{business_name}". Highlight its services, quality, and trust. Keep it under 250 characters. [/INST]"""
9
- output = llm(prompt, max_tokens=200, temperature=0.7, stop=["</s>"])
10
- return output['choices'][0]['text'].strip()
 
 
 
11
 
12
  gr.Interface(
13
  fn=generate_description,
14
  inputs=gr.Textbox(label="Business Name", placeholder="e.g. Pizza House"),
15
  outputs="text",
16
- title="GMB Description Generator (Mistral)",
17
- description="Generate SEO-optimized business descriptions using Mistral-7B-GGUF."
18
  ).launch()
 
1
  from llama_cpp import Llama
2
  import gradio as gr
3
 
4
+ # Load the model from Hugging Face Hub (ensure the GGUF model is downloaded or available locally)
5
+ llm = Llama(
6
+ model_path="./TheBloke_Mistral-7B-Instruct-v0.1-GGUF.Q4_K_M.gguf", # use correct filename here
7
+ n_ctx=2048,
8
+ n_threads=4,
9
+ n_batch=64
10
+ )
11
 
12
  def generate_description(business_name):
13
+ prompt = (
14
+ f"Write a professional and SEO-friendly Google My Business description for a business called '{business_name}'. "
15
+ f"Keep it under 250 characters and highlight key services, trust, and quality. Use keywords like pizza, delivery, dine-in, or family-friendly."
16
+ )
17
+ response = llm(prompt=prompt, max_tokens=256, temperature=0.7)
18
+ return response["choices"][0]["text"].strip()
19
 
20
  gr.Interface(
21
  fn=generate_description,
22
  inputs=gr.Textbox(label="Business Name", placeholder="e.g. Pizza House"),
23
  outputs="text",
24
+ title="GMB Description Generator",
25
+ description="Generate SEO-optimized Google My Business descriptions using Mistral-7B-GGUF"
26
  ).launch()