|
## yaml-language-server: $schema=https://raw.githubusercontent.com/julep-ai/julep/refs/heads/dev/schemas/create_task_request.json |
|
|
|
|
|
# Subworkflow that, given product data, will generate FAQs for the product |
|
# add them along with other product details to the agent's doc store |
|
index_product: |
|
|
|
# Extract useful information from metadata |
|
- evaluate: |
|
filtered_metadata: | |
|
$ { |
|
'name': steps[0].input.data.get('name', None), # Product name |
|
'brand': steps[0].input.data.get('brand', {}).get('name', None), # Brand information |
|
'price': {'min': steps[0].input.data.get('price', None).get('effective', {}).get('min', None), |
|
'max': steps[0].input.data.get('price', None).get('effective', {}).get('max', None), |
|
'currency': steps[0].input.data.get('price', None).get('effective', {}).get('currency_code', None)}, # Price details |
|
'categories': steps[0].input.data.get('categories', None), # Product categories |
|
'country_of_origin': steps[0].input.data.get('country_of_origin', None), # Manufacturing country |
|
'tags': steps[0].input.data.get('tags', None), # Product tags |
|
'item_type': steps[0].input.data.get('item_type', None), # Type of item |
|
'teaser_tag': steps[0].input.data.get('teaser_tag', None), # Promotional tag |
|
'attributes': { |
|
'skin_type': steps[0].input.data.get('attributes', {}).get('skin-type', None), |
|
'gender': steps[0].input.data.get('attributes', {}).get('gender', None), |
|
'discount': steps[0].input.data.get('attributes', {}).get('discount', None), |
|
'preference': steps[0].input.data.get('attributes', {}).get('preference', None), |
|
'category-l1': steps[0].input.data.get('attributes', {}).get('category-l1', None), |
|
'category-l2': steps[0].input.data.get('attributes', {}).get('category-l2', None), |
|
'benefits': steps[0].input.data.get('attributes', {}).get('benefits', None), |
|
'category-l3': steps[0].input.data.get('attributes', {}).get('category-l3', None), |
|
'productaffluence': steps[0].input.data.get('attributes', {}).get('productaffluence', None), |
|
'concern': steps[0].input.data.get('attributes', {}).get('concern', None), |
|
'formulation': steps[0].input.data.get('attributes', {}).get('formulation', None), |
|
'super-ingredients': steps[0].input.data.get('attributes', {}).get('super-ingredients', None), |
|
'variants': steps[0].input.data.get('variants', None)} |
|
} |
|
|
|
# A prompt step that generate FAQs based on the scraped content |
|
- prompt: |
|
# A system prompt that instructs the LLM to generate FAQs based on the scraped content |
|
- role: system |
|
content: |- |
|
You are a helpful assistant that is tasked with indexing the products from the Tira Beauty website. |
|
You will be given: |
|
- product name. |
|
- a markdown content of that represents a description for a beauty product found on an e-commerce website. |
|
- data dump of other information and metadata about the product. |
|
<task> |
|
- Read the markdown content very carefully. |
|
- Pay attention to information listed in the data dump. |
|
- Come up with a FAQ for the product based on the content. |
|
- Answer the FAQ in a structured format. |
|
- Return your response in JSON format has the following fields for each FAQ: |
|
- question: The question of the FAQ. |
|
- answer: The answer of the FAQ. |
|
</task> |
|
|
|
<Important> |
|
- Only come up with FAQs that are relevant to the product, and that can be answered based on the provided content. |
|
- Make sure your response is a valid JSON list of objects that have `question` and `answer` fields. |
|
- Make sure to surround the JSON response with ```json``` tags. |
|
</Important> |
|
|
|
Example of FAQ: |
|
- What are the benefits of using the product? |
|
- What are the ingredients of the product? |
|
- Does the product have any side effects? |
|
- What are the chemicals in the product? |
|
- What kind of skin type is the product for? |
|
- What are the uses of the product? |
|
- What are the precautions of using the product? |
|
- What are the contraindications of using the product? |
|
- What are the interactions of the product? |
|
- What are the storage instructions of the product? |
|
- What are the expiration date of the product? |
|
|
|
# A user prompt that provides the product data to the LLM |
|
- role: user |
|
content: |- |
|
$ f""" |
|
<product_name> |
|
{steps[0].input.name} |
|
</product_name> |
|
|
|
<product_description> |
|
{steps[0].input.description} |
|
</product_description> |
|
|
|
<other_product_data> |
|
{steps[0].output.filtered_metadata} |
|
</other_product_data> |
|
""" |
|
|
|
# Unwrap (response.choices[0].message.content) and provide the response text to the next step |
|
unwrap: true |
|
|
|
# Extract the FAQs from the LLM's json response |
|
- evaluate: |
|
faqs: $ extract_json(_) |
|
|
|
# Prompt step to rewrite everything as points (will be used as content for the document that will be created) |
|
- prompt: |
|
# A system prompt that instructs the LLM to rewrite the document, FAQs and context as points. |
|
- role: system |
|
content: |- |
|
You are an agent who works for a Tira Beauty company, who is tasked with rewriting product description, FAQs, metadata as points. |
|
You will be given: |
|
- a markdown content of that represents a description for a beauty product found on an e-commerce website. |
|
- a list of FAQs for the product. |
|
- metadata about the product including details like name, brand, price, rating, categories, etc. |
|
<task> |
|
- Rewrite the document, FAQs, metadata as points. Optimize the final document for search retrieval. |
|
- Include relevant metadata in your points to enhance searchability. |
|
</task> |
|
|
|
# A user prompt that provides the product data to the LLM |
|
- role: user |
|
content: |- |
|
$ f""" |
|
<document> |
|
{steps[0].input.description} |
|
</document> |
|
|
|
<faqs> |
|
{'\\n\\n'.join([f'## {faq["question"]}\\n{faq["answer"]}' for faq in _.faqs])} |
|
</faqs> |
|
|
|
<metadata> |
|
{steps[0].output.filtered_metadata} |
|
</metadata> |
|
""" |
|
|
|
# Unwrap `response.choices[0].message.content` and provide the response text to the next step |
|
unwrap: true |
|
|
|
# Create the document |
|
- tool: create_agent_doc |
|
arguments: |
|
agent_id: $ str(agent.id) |
|
data: |
|
metadata: $ steps[0].input.data |
|
title: $ steps[0].input.name |
|
content: $ _ |