File tree Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Expand file tree Collapse file tree 4 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,6 @@ services:
6868 nats-indexer :
6969 deploy :
7070 replicas : 1
71- restart : always
7271 image : ghcr.io/heussd/nats-news-analysis/nats-indexer:latest
7372 environment :
7473 - ' NATS_URL=nats-server:4222'
Original file line number Diff line number Diff line change 11pub-article :
2- nats pub article-urls " {\" url\" : \" https://www.tagesschau.de/ausland/indien-satellit-102.html\" }"
2+ nats pub article-urls " {\" url\" : \" https://www.tagesschau.de/ausland/indien-satellit-102.html\" }"
3+
4+ 5 :
5+ $(MAKE ) pub-article
6+ $(MAKE ) pub-article
7+ $(MAKE ) pub-article
8+ $(MAKE ) pub-article
9+ $(MAKE ) pub-article
Original file line number Diff line number Diff line change 66import requests
77
88
9- def add (searchDocs : List [dict ]):
9+ def add (searchDocs : List [dict ]) -> bool :
1010 if len (searchDocs ) == 0 :
1111 print ("No documents to add." )
1212 return
@@ -22,9 +22,12 @@ def add(searchDocs: List[dict]):
2222 data = json .dumps (data , cls = NumpyEncoder ),
2323 )
2424
25- res .raise_for_status ()
2625 if res .status_code == 200 :
2726 print (f"{ len (searchDocs )} documents added to the search index successfully." )
27+ return True
28+ else :
29+ print (f"Failed to add documents to the search index. Status code: { res .status_code } , Status text: { res .text } " )
30+ return False
2831
2932
3033def search (query : str ):
Original file line number Diff line number Diff line change @@ -22,7 +22,8 @@ async def process(msgs: List[nats.aio.msg.Msg]):
2222 url = json_data ["url" ],
2323 ))
2424 prepared_search_docs = prepare (jsonmsgs )
25- add (prepared_search_docs )
25+ if not add (prepared_search_docs ):
26+ raise Exception ("Failed to add documents to AI search index" )
2627
2728
2829async def run ():
You can’t perform that action at this time.
0 commit comments