thanhnt-cf's picture
initial commit
8ba64a4
raw
history blame
1.46 kB
from functools import lru_cache
from typing import Optional
from pydantic_settings import BaseSettings
EXTRACT_INFO_SYSTEM = "You are an expert at structured data extraction. You will be given an image of a product and should output the its properties into the given structure."
EXTRACT_INFO_HUMAN = (
"""Output properties of the {product_taxonomy} product in the images. You should use the following attributes to help you if it exists:
{product_data}
If an attribute is both in the image and the attributes, use the one in the attribute."""
).replace(" ", "")
FOLLOW_SCHEMA_SYSTEM = "You are an expert at structured data extraction. You will be given an dictionary of attributes of a product and should output the its properties into the given structure."
FOLLOW_SCHEMA_HUMAN = """Convert following attributes to structured schema. Keep all the keys and number of values. Only replace the values themselves. :
{json_info}"""
class Prompts(BaseSettings):
EXTRACT_INFO_SYSTEM_MESSAGE: str = EXTRACT_INFO_SYSTEM
EXTRACT_INFO_HUMAN_MESSAGE: str = EXTRACT_INFO_HUMAN
FOLLOW_SCHEMA_SYSTEM_MESSAGE: str = FOLLOW_SCHEMA_SYSTEM
FOLLOW_SCHEMA_HUMAN_MESSAGE: str = FOLLOW_SCHEMA_HUMAN
# Create a cached instance of settings
@lru_cache
def get_prompts() -> Prompts:
"""
Create and cache a Prompts instance.
Returns the same instance for subsequent calls.
"""
prompts = Prompts()
return prompts