googlecodelabs / feedback

Provide feedback to our codelabs by filing an issue here
18 stars 22 forks source link

[smart-shop-agent-alloydb] #1426

Open msanaulla opened 2 months ago

msanaulla commented 2 months ago

In this query:

select id, description, LLM_RESPONSE from (
SELECT id, user_text, description, category, sub_category, uri,
ML_PREDICT_ROW(
'projects/abis-345004/locations/us-central1/publishers/google/models/text-bison',
    json_build_object(
        'instances', json_build_array(
            json_build_object(
                'prompt', 'Read this user search text: ' || user_text || ' Compare it against the product record: ' || content || ' Return a response with 3 values: 1) MATCH: if the 2 products are at least 85% matching or not: YES or NO 2) PERCENTAGE: percentage of match, make sure that this percentage is accurate 3) DIFFERENCE: A clear short easy description of the difference between the 2 products. Remember if the user search text says that some attribute should not be there, and the product record has it, it should be a NO match.'
            )
        ),
        'parameters', json_build_object(
            'maxOutputTokens', 1024,
            'topK', 40,
            'topP', 0.8,
            'temperature', 0.2
        )
    )
) -> 'predictions' -> 0 -> 'content' AS LLM_RESPONSE
FROM  (
SELECT 'I want womens footwear, black color, with heels and strictly no leather.' user_text, id, category, sub_category, uri, content, pdt_desc  as description FROM apparels
ORDER BY embedding <=> embedding('textembedding-gecko@003', 'I want womens footwear, black color, with heels and strictly no leather.')::vector LIMIT 25) as xyz
) as X
where cast(LLM_RESPONSE as VARCHAR(500)) like '%MATCH:%YES%' limit 10;

For The URL: projects/abis-345004/locations/us-central1/publishers/google/models/text-bison we need to mention the reader to replace abis-345004 with their project id.