Skip to content

Commit 0d4fcab

Browse files
committed
update vs
1 parent 63309bf commit 0d4fcab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tinybird/endpoints/llm_messages.pipe

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ NODE llm_messages_node
77
SQL >
88
%
99
{% if defined(embedding) %}
10-
with cosineDistance(embedding, {{ Array(embedding, 'Float32') }}) as similarity
10+
with if(length(embedding) == 0, 1, cosineDistance(embedding, {{ Array(embedding, 'Float32') }})) as similarity
1111
{% end %}
1212
SELECT
1313
timestamp,
@@ -27,7 +27,7 @@ SQL >
2727
response_status,
2828
exception
2929
{% if defined(embedding) %}
30-
, similarity
30+
, 1 - similarity
3131
{% else %}
3232
, 0 as similarity
3333
{% end %}
@@ -69,7 +69,7 @@ SQL >
6969
AND timestamp < {{DateTime(end_date)}}
7070
{% end %}
7171
{% if defined(embedding) %}
72-
AND length(embedding) > 0 and similarity > {{ Float64(similarity_threshold, 0.3) }}
72+
AND length(embedding) > 0 and similarity <= {{ Float64(similarity_threshold, 0.3) }}
7373
and response_status != 'error'
7474
{% end %}
7575
{% if defined(embedding) %}

0 commit comments

Comments
 (0)