Skip to content

Commit f81b5d1

Browse files
committed
Run setup search regularly + add logic to wait for it to be ready
1 parent a607f63 commit f81b5d1

File tree

1 file changed

+81
-44
lines changed

1 file changed

+81
-44
lines changed

.github/workflows/setup-search-index.yml

Lines changed: 81 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Setup Search Index
22

33
on:
44
workflow_run:
5-
workflows: ["Build Search Index"]
5+
workflows: ["Build Search Index", "pages-build-deployment"]
66
types:
77
- completed
88
workflow_dispatch:
@@ -11,58 +11,95 @@ jobs:
1111
init-conversation-store:
1212
runs-on: ubuntu-latest
1313
steps:
14+
- name: Wait for deployment to be ready
15+
run: |
16+
echo "Waiting for search service to be ready..."
17+
for i in {1..30}; do
18+
if curl -s -f -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" https://search.docs.servicestack.net/health > /dev/null 2>&1; then
19+
echo "Search service is ready!"
20+
exit 0
21+
fi
22+
echo "Attempt $i/30: Service not ready yet, waiting..."
23+
sleep 10
24+
done
25+
echo "Warning: Service may not be fully ready, proceeding anyway..."
26+
env:
27+
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
28+
1429
- name: Create conversation store collection
1530
env:
1631
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
1732
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
1833
run: |
19-
curl 'https://search.docs.servicestack.net/collections' \
20-
-X POST \
21-
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
22-
-H 'Content-Type: application/json' \
23-
-d '{
24-
"name": "conversation_store",
25-
"fields": [
26-
{
27-
"name": "conversation_id",
28-
"type": "string"
29-
},
30-
{
31-
"name": "model_id",
32-
"type": "string"
33-
},
34-
{
35-
"name": "timestamp",
36-
"type": "int32"
37-
},
38-
{
39-
"name": "role",
40-
"type": "string",
41-
"index": false
42-
},
43-
{
44-
"name": "message",
45-
"type": "string",
46-
"index": false
47-
}
48-
]
49-
}'
34+
# Retry logic for creating conversation store collection
35+
for attempt in {1..5}; do
36+
echo "Attempt $attempt/5: Creating conversation store collection..."
37+
if curl -s -X POST 'https://search.docs.servicestack.net/collections' \
38+
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
39+
-H 'Content-Type: application/json' \
40+
-d '{
41+
"name": "conversation_store",
42+
"fields": [
43+
{
44+
"name": "conversation_id",
45+
"type": "string"
46+
},
47+
{
48+
"name": "model_id",
49+
"type": "string"
50+
},
51+
{
52+
"name": "timestamp",
53+
"type": "int32"
54+
},
55+
{
56+
"name": "role",
57+
"type": "string",
58+
"index": false
59+
},
60+
{
61+
"name": "message",
62+
"type": "string",
63+
"index": false
64+
}
65+
]
66+
}' | grep -q "conversation_store"; then
67+
echo "Successfully created conversation store collection"
68+
exit 0
69+
fi
70+
if [ $attempt -lt 5 ]; then
71+
echo "Failed, retrying in 5 seconds..."
72+
sleep 5
73+
fi
74+
done
75+
echo "Warning: Could not create conversation store collection after 5 attempts"
5076
5177
- name: Create or update conversation model
5278
env:
5379
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
5480
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
5581
run: |
56-
curl 'https://search.docs.servicestack.net/conversations/models' \
57-
-X POST \
58-
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
59-
-H 'Content-Type: application/json' \
60-
-d '{
61-
"id": "conv-model-1",
62-
"model_name": "google/gemini-flash-latest",
63-
"history_collection": "conversation_store",
64-
"api_key": "'"${GOOGLE_API_KEY}"'",
65-
"system_prompt": "You are an intelligent assistant for question-answering about ServiceStack Software. Try to answer questions using the provided context. If a response has no references in the provided context, politely say you do not have knowledge about that topic.",
66-
"max_bytes": 16384
67-
}'
82+
# Retry logic for creating/updating conversation model
83+
for attempt in {1..5}; do
84+
echo "Attempt $attempt/5: Creating/updating conversation model..."
85+
if curl -s -X POST 'https://search.docs.servicestack.net/conversations/models' \
86+
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
87+
-H 'Content-Type: application/json' \
88+
-d '{
89+
"id": "conv-model-1",
90+
"model_name": "google/gemini-flash-latest",
91+
"history_collection": "conversation_store",
92+
"api_key": "'"${GOOGLE_API_KEY}"'",
93+
"system_prompt": "You are an intelligent assistant for question-answering about ServiceStack Software. Try to answer questions using the provided context. If a response has no references in the provided context, politely say you do not have knowledge about that topic.",
94+
"max_bytes": 16384
95+
}' | grep -q "conv-model-1"; then
96+
echo "Successfully created/updated conversation model"
97+
exit 0
98+
fi
99+
if [ $attempt -lt 5 ]; then
100+
echo "Failed, retrying in 5 seconds..."
101+
sleep 5
102+
fi
103+
done
104+
echo "Warning: Could not create/update conversation model after 5 attempts"
68105

0 commit comments

Comments
 (0)