-
Notifications
You must be signed in to change notification settings - Fork 4
104 lines (100 loc) · 4.04 KB
/
setup-search-index.yml
File metadata and controls
104 lines (100 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Setup Search Index
on:
workflow_run:
workflows: ["Build Search Index", "pages-build-deployment"]
types:
- completed
workflow_dispatch:
jobs:
init-conversation-store:
runs-on: ubuntu-latest
steps:
- name: Wait for deployment to be ready
run: |
echo "Waiting for search service to be ready..."
for i in {1..30}; do
if curl -s -f -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" https://search.docs.servicestack.net/health > /dev/null 2>&1; then
echo "Search service is ready!"
exit 0
fi
echo "Attempt $i/30: Service not ready yet, waiting..."
sleep 10
done
echo "Warning: Service may not be fully ready, proceeding anyway..."
env:
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
- name: Create conversation store collection
env:
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: |
# Retry logic for creating conversation store collection
for attempt in {1..5}; do
echo "Attempt $attempt/5: Creating conversation store collection..."
if curl -s -X POST 'https://search.docs.servicestack.net/collections' \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"name": "conversation_store",
"fields": [
{
"name": "conversation_id",
"type": "string"
},
{
"name": "model_id",
"type": "string"
},
{
"name": "timestamp",
"type": "int32"
},
{
"name": "role",
"type": "string",
"index": false
},
{
"name": "message",
"type": "string",
"index": false
}
]
}' | grep -q "conversation_store"; then
echo "Successfully created conversation store collection"
exit 0
fi
if [ $attempt -lt 5 ]; then
echo "Failed, retrying in 5 seconds..."
sleep 5
fi
done
echo "Warning: Could not create conversation store collection after 5 attempts"
- name: Create or update conversation model
env:
TYPESENSE_API_KEY: ${{ secrets.TYPESENSE_API_KEY }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
run: |
# Retry logic for creating/updating conversation model
for attempt in {1..5}; do
echo "Attempt $attempt/5: Creating/updating conversation model..."
if curl -s -X POST 'https://search.docs.servicestack.net/conversations/models' \
-H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
-H 'Content-Type: application/json' \
-d '{
"id": "conv-model-1",
"model_name": "google/gemini-flash-latest",
"history_collection": "conversation_store",
"api_key": "'"${GOOGLE_API_KEY}"'",
"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.",
"max_bytes": 16384
}' | grep -q "conv-model-1"; then
echo "Successfully created/updated conversation model"
exit 0
fi
if [ $attempt -lt 5 ]; then
echo "Failed, retrying in 5 seconds..."
sleep 5
fi
done
echo "Warning: Could not create/update conversation model after 5 attempts"