Update app.py
Browse files
app.py
CHANGED
@@ -49,6 +49,12 @@ def format_prompt(message, history):
|
|
49 |
|
50 |
def getProductDetails(history, image):
|
51 |
product_description=getImageDescription(image)
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
client = InferenceClient("google/gemma-7b-it")
|
53 |
rand_val = random.randint(1, 1111111111111111)
|
54 |
if not history:
|
@@ -61,8 +67,6 @@ def getProductDetails(history, image):
|
|
61 |
do_sample=True,
|
62 |
seed=rand_val,
|
63 |
)
|
64 |
-
system_prompt="You're a helpful e-commerce marketing assitant working on art products."
|
65 |
-
prompt="Our product description is as follows: " + product_description + ". Please write a product title options for it."
|
66 |
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
67 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
68 |
output = ""
|
|
|
49 |
|
50 |
def getProductDetails(history, image):
|
51 |
product_description=getImageDescription(image)
|
52 |
+
system_prompt="You're a helpful e-commerce marketing assitant working on art products."
|
53 |
+
prompt="Our product description is as follows: " + product_description + ". Please write a product title options for it."
|
54 |
+
history = interactWithModel(history, system_prompt, prompt)
|
55 |
+
yield history
|
56 |
+
|
57 |
+
def interactWithModel(history, system_prompt, prompt):
|
58 |
client = InferenceClient("google/gemma-7b-it")
|
59 |
rand_val = random.randint(1, 1111111111111111)
|
60 |
if not history:
|
|
|
67 |
do_sample=True,
|
68 |
seed=rand_val,
|
69 |
)
|
|
|
|
|
70 |
formatted_prompt = format_prompt(f"{system_prompt}, {prompt}", history)
|
71 |
stream = client.text_generation(formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
|
72 |
output = ""
|