Spaces:
Runtime error
Runtime error
Major update
Browse files
app.py
CHANGED
|
@@ -7,17 +7,27 @@ import random
|
|
| 7 |
checkpoint = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 8 |
client = InferenceClient(checkpoint)
|
| 9 |
|
|
|
|
| 10 |
def format_prompt(raw_Prompt):
|
| 11 |
better_prompt = f"[INST] {raw_Prompt} [/INST]"
|
| 12 |
return better_prompt
|
| 13 |
|
| 14 |
|
| 15 |
-
def findShops(target_platform, target_region, target_field, target_rangeFrom, target_rangeTo, target_crossSelling, target_similarArticles, target_amount,accessKey):
|
| 16 |
if accessKey != 'Kuchen':
|
| 17 |
return 'You are not authorized to use this software.'
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
Make sure the recommended shops are located in {target_region}.
|
|
|
|
|
|
|
| 21 |
The websites of the recommended shops should have between {target_rangeFrom} and {target_rangeTo} monthly visitors."""
|
| 22 |
crossSellingPrompt = """
|
| 23 |
The recommended shops should be potential customers for a software that improves the cross-selling on their website."""
|
|
@@ -26,10 +36,17 @@ def findShops(target_platform, target_region, target_field, target_rangeFrom, ta
|
|
| 26 |
fieldPrompt = f"""
|
| 27 |
Focus on shops that have a focus on the topic'{target_field}'."""
|
| 28 |
stylePrompt = """
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
if target_crossSelling:
|
| 34 |
fullPrompt += crossSellingPrompt
|
| 35 |
if target_similarArticles:
|
|
@@ -66,7 +83,7 @@ with gr.Blocks(title="Shop finder",
|
|
| 66 |
with gr.Group():
|
| 67 |
gr.Markdown("**FILTERS**")
|
| 68 |
with gr.Column():
|
| 69 |
-
platform = gr.Dropdown(choices=['Shopware', 'Shopify'],
|
| 70 |
value='Shopware',
|
| 71 |
interactive=True,
|
| 72 |
label="PLATFORM")
|
|
@@ -112,22 +129,21 @@ with gr.Blocks(title="Shop finder",
|
|
| 112 |
btn = gr.Button("FIND")
|
| 113 |
with gr.Group():
|
| 114 |
gr.Markdown("**RESULTS**")
|
| 115 |
-
out = gr.
|
| 116 |
-
|
| 117 |
-
label='POTENTIAL SHOPS')
|
| 118 |
with gr.Group():
|
| 119 |
gr.Markdown("*ACCESS SECRET*")
|
| 120 |
loginKey = gr.Textbox(max_lines=1,
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
btn.click(fn=findShops,
|
| 125 |
inputs=[platform, region, field,
|
| 126 |
range_from, range_to,
|
| 127 |
opt_crossSelling,
|
| 128 |
opt_similarArticles,
|
| 129 |
numberOfShops,
|
| 130 |
-
|
| 131 |
outputs=out)
|
| 132 |
|
| 133 |
demo.launch(show_api=False)
|
|
|
|
| 7 |
checkpoint = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 8 |
client = InferenceClient(checkpoint)
|
| 9 |
|
| 10 |
+
|
| 11 |
def format_prompt(raw_Prompt):
|
| 12 |
better_prompt = f"[INST] {raw_Prompt} [/INST]"
|
| 13 |
return better_prompt
|
| 14 |
|
| 15 |
|
| 16 |
+
def findShops(target_platform, target_region, target_field, target_rangeFrom, target_rangeTo, target_crossSelling, target_similarArticles, target_amount, accessKey):
|
| 17 |
if accessKey != 'Kuchen':
|
| 18 |
return 'You are not authorized to use this software.'
|
| 19 |
+
if target_platform == 'All':
|
| 20 |
+
basePrompt = f"""
|
| 21 |
+
Search for {target_amount} Shops with a website.
|
| 22 |
+
"""
|
| 23 |
+
else:
|
| 24 |
+
basePrompt = f"""
|
| 25 |
+
Search for {target_amount} Shops that use the platform {target_platform}.
|
| 26 |
+
"""
|
| 27 |
+
regionPrompt = f"""
|
| 28 |
Make sure the recommended shops are located in {target_region}.
|
| 29 |
+
"""
|
| 30 |
+
rangePrompt = f"""
|
| 31 |
The websites of the recommended shops should have between {target_rangeFrom} and {target_rangeTo} monthly visitors."""
|
| 32 |
crossSellingPrompt = """
|
| 33 |
The recommended shops should be potential customers for a software that improves the cross-selling on their website."""
|
|
|
|
| 36 |
fieldPrompt = f"""
|
| 37 |
Focus on shops that have a focus on the topic'{target_field}'."""
|
| 38 |
stylePrompt = """
|
| 39 |
+
Your response must be a list in markdown format.
|
| 40 |
+
Each element of the list must follow these rules:
|
| 41 |
+
- The title for each element must be the name of the shop.
|
| 42 |
+
- The information coming after the title must each start in a new line.
|
| 43 |
+
- The first information for each element must be a link to the website.
|
| 44 |
+
- The next information must always be the number of monthly website visitors.
|
| 45 |
+
- The next information must always be a summary of what is sold in the shop.
|
| 46 |
+
"""
|
| 47 |
+
fullPrompt = basePrompt
|
| 48 |
+
fullPrompt += regionPrompt
|
| 49 |
+
fullPrompt += rangePrompt
|
| 50 |
if target_crossSelling:
|
| 51 |
fullPrompt += crossSellingPrompt
|
| 52 |
if target_similarArticles:
|
|
|
|
| 83 |
with gr.Group():
|
| 84 |
gr.Markdown("**FILTERS**")
|
| 85 |
with gr.Column():
|
| 86 |
+
platform = gr.Dropdown(choices=['All', 'Shopware', 'Shopify'],
|
| 87 |
value='Shopware',
|
| 88 |
interactive=True,
|
| 89 |
label="PLATFORM")
|
|
|
|
| 129 |
btn = gr.Button("FIND")
|
| 130 |
with gr.Group():
|
| 131 |
gr.Markdown("**RESULTS**")
|
| 132 |
+
out = gr.Markdown(value=' <br /> <br /> <br /> <br /> <br /> <br />',
|
| 133 |
+
label='POTENTIAL SHOPS')
|
|
|
|
| 134 |
with gr.Group():
|
| 135 |
gr.Markdown("*ACCESS SECRET*")
|
| 136 |
loginKey = gr.Textbox(max_lines=1,
|
| 137 |
+
interactive=True,
|
| 138 |
+
type='password',
|
| 139 |
+
show_label=False)
|
| 140 |
btn.click(fn=findShops,
|
| 141 |
inputs=[platform, region, field,
|
| 142 |
range_from, range_to,
|
| 143 |
opt_crossSelling,
|
| 144 |
opt_similarArticles,
|
| 145 |
numberOfShops,
|
| 146 |
+
loginKey],
|
| 147 |
outputs=out)
|
| 148 |
|
| 149 |
demo.launch(show_api=False)
|