Spaces:
Running
Running
rdmlx commited on
Commit Β·
d9c155c
1
Parent(s): b3dfc35
Simplify API: Remove book/testament filters, search entire Bible by default
Browse files- Remove books and testament optional parameters from SearchRequest
- Always search all 66 books (Old and New Testament)
- Update all documentation to reflect simplified API
- Remove Book Abbreviations section from README
- Update all code examples to use only query and limit parameters
- API_DOCUMENTATION.md +13 -86
- README.md +2 -13
- app.py +3 -24
API_DOCUMENTATION.md
CHANGED
|
@@ -65,15 +65,13 @@ curl https://dssjon-biblos-api.hf.space/health
|
|
| 65 |
|
| 66 |
**POST /search**
|
| 67 |
|
| 68 |
-
Perform semantic search over Bible
|
| 69 |
|
| 70 |
#### Request Body
|
| 71 |
|
| 72 |
| Field | Type | Required | Description |
|
| 73 |
|-------|------|----------|-------------|
|
| 74 |
| `query` | string | Yes | Search query text (1-500 chars) |
|
| 75 |
-
| `books` | array[string] | No | Filter by book abbreviations |
|
| 76 |
-
| `testament` | string | No | Filter by testament: "old" or "new" |
|
| 77 |
| `limit` | integer | No | Number of results (1-100, default: 10) |
|
| 78 |
|
| 79 |
#### Response
|
|
@@ -95,9 +93,8 @@ Perform semantic search over Bible text.
|
|
| 95 |
}
|
| 96 |
```
|
| 97 |
|
| 98 |
-
####
|
| 99 |
|
| 100 |
-
##### Basic Search
|
| 101 |
```bash
|
| 102 |
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 103 |
-H "Content-Type: application/json" \
|
|
@@ -107,45 +104,6 @@ curl -X POST https://dssjon-biblos-api.hf.space/search \
|
|
| 107 |
}'
|
| 108 |
```
|
| 109 |
|
| 110 |
-
##### Search by Testament
|
| 111 |
-
```bash
|
| 112 |
-
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 113 |
-
-H "Content-Type: application/json" \
|
| 114 |
-
-d '{
|
| 115 |
-
"query": "love your enemies",
|
| 116 |
-
"testament": "new",
|
| 117 |
-
"limit": 10
|
| 118 |
-
}'
|
| 119 |
-
```
|
| 120 |
-
|
| 121 |
-
##### Search Specific Books
|
| 122 |
-
```bash
|
| 123 |
-
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 124 |
-
-H "Content-Type: application/json" \
|
| 125 |
-
-d '{
|
| 126 |
-
"query": "the beginning",
|
| 127 |
-
"books": ["gen", "jhn"],
|
| 128 |
-
"limit": 5
|
| 129 |
-
}'
|
| 130 |
-
```
|
| 131 |
-
|
| 132 |
-
---
|
| 133 |
-
|
| 134 |
-
## Book Abbreviations
|
| 135 |
-
|
| 136 |
-
### Old Testament (39 books)
|
| 137 |
-
```
|
| 138 |
-
gen, exo, lev, num, deu, jos, jdg, rut, 1sa, 2sa, 1ki, 2ki, 1ch, 2ch,
|
| 139 |
-
ezr, neh, est, job, psa, pro, ecc, sng, isa, jer, lam, ezk, dan, hos,
|
| 140 |
-
jol, amo, oba, jon, mic, nam, hab, zep, hag, zec, mal
|
| 141 |
-
```
|
| 142 |
-
|
| 143 |
-
### New Testament (27 books)
|
| 144 |
-
```
|
| 145 |
-
mat, mrk, luk, jhn, act, rom, 1co, 2co, gal, eph, php, col, 1th, 2th,
|
| 146 |
-
1ti, 2ti, tit, phm, heb, jas, 1pe, 2pe, 1jn, 2jn, 3jn, jud, rev
|
| 147 |
-
```
|
| 148 |
-
|
| 149 |
---
|
| 150 |
|
| 151 |
## Integration Examples
|
|
@@ -154,7 +112,7 @@ mat, mrk, luk, jhn, act, rom, 1co, 2co, gal, eph, php, col, 1th, 2th,
|
|
| 154 |
|
| 155 |
#### Basic Fetch
|
| 156 |
```javascript
|
| 157 |
-
async function searchBible(query,
|
| 158 |
const response = await fetch('https://dssjon-biblos-api.hf.space/search', {
|
| 159 |
method: 'POST',
|
| 160 |
headers: {
|
|
@@ -162,7 +120,7 @@ async function searchBible(query, options = {}) {
|
|
| 162 |
},
|
| 163 |
body: JSON.stringify({
|
| 164 |
query,
|
| 165 |
-
|
| 166 |
})
|
| 167 |
})
|
| 168 |
|
|
@@ -174,10 +132,7 @@ async function searchBible(query, options = {}) {
|
|
| 174 |
}
|
| 175 |
|
| 176 |
// Usage
|
| 177 |
-
const results = await searchBible('love one another',
|
| 178 |
-
testament: 'new',
|
| 179 |
-
limit: 5
|
| 180 |
-
})
|
| 181 |
|
| 182 |
console.log(results)
|
| 183 |
```
|
|
@@ -186,12 +141,6 @@ console.log(results)
|
|
| 186 |
```typescript
|
| 187 |
import { useState, useCallback } from 'react'
|
| 188 |
|
| 189 |
-
interface SearchOptions {
|
| 190 |
-
books?: string[]
|
| 191 |
-
testament?: 'old' | 'new'
|
| 192 |
-
limit?: number
|
| 193 |
-
}
|
| 194 |
-
|
| 195 |
interface SearchResult {
|
| 196 |
book: string
|
| 197 |
chapter: number
|
|
@@ -206,7 +155,7 @@ export function useBibleSearch() {
|
|
| 206 |
|
| 207 |
const search = useCallback(async (
|
| 208 |
query: string,
|
| 209 |
-
|
| 210 |
): Promise<SearchResult[]> => {
|
| 211 |
setLoading(true)
|
| 212 |
setError(null)
|
|
@@ -215,7 +164,7 @@ export function useBibleSearch() {
|
|
| 215 |
const response = await fetch('https://dssjon-biblos-api.hf.space/search', {
|
| 216 |
method: 'POST',
|
| 217 |
headers: { 'Content-Type': 'application/json' },
|
| 218 |
-
body: JSON.stringify({ query,
|
| 219 |
})
|
| 220 |
|
| 221 |
if (!response.ok) {
|
|
@@ -242,7 +191,7 @@ function SearchComponent() {
|
|
| 242 |
const [results, setResults] = useState([])
|
| 243 |
|
| 244 |
const handleSearch = async (query: string) => {
|
| 245 |
-
const results = await search(query,
|
| 246 |
setResults(results)
|
| 247 |
}
|
| 248 |
|
|
@@ -260,14 +209,12 @@ function SearchComponent() {
|
|
| 260 |
```python
|
| 261 |
import requests
|
| 262 |
|
| 263 |
-
def search_bible(query,
|
| 264 |
"""
|
| 265 |
Search the Bible using semantic search
|
| 266 |
|
| 267 |
Args:
|
| 268 |
query: Search query text
|
| 269 |
-
books: Optional list of book abbreviations
|
| 270 |
-
testament: Optional filter ('old' or 'new')
|
| 271 |
limit: Number of results to return
|
| 272 |
|
| 273 |
Returns:
|
|
@@ -280,11 +227,6 @@ def search_bible(query, books=None, testament=None, limit=10):
|
|
| 280 |
'limit': limit
|
| 281 |
}
|
| 282 |
|
| 283 |
-
if books:
|
| 284 |
-
payload['books'] = books
|
| 285 |
-
if testament:
|
| 286 |
-
payload['testament'] = testament
|
| 287 |
-
|
| 288 |
response = requests.post(url, json=payload)
|
| 289 |
response.raise_for_status()
|
| 290 |
|
|
@@ -293,7 +235,6 @@ def search_bible(query, books=None, testament=None, limit=10):
|
|
| 293 |
# Usage
|
| 294 |
results = search_bible(
|
| 295 |
query='faith and works',
|
| 296 |
-
testament='new',
|
| 297 |
limit=5
|
| 298 |
)
|
| 299 |
|
|
@@ -309,11 +250,11 @@ for result in results['results']:
|
|
| 309 |
import asyncio
|
| 310 |
import aiohttp
|
| 311 |
|
| 312 |
-
async def search_bible_async(query,
|
| 313 |
"""Async version of Bible search"""
|
| 314 |
url = 'https://dssjon-biblos-api.hf.space/search'
|
| 315 |
|
| 316 |
-
payload = {'query': query,
|
| 317 |
|
| 318 |
async with aiohttp.ClientSession() as session:
|
| 319 |
async with session.post(url, json=payload) as response:
|
|
@@ -322,11 +263,7 @@ async def search_bible_async(query, **kwargs):
|
|
| 322 |
|
| 323 |
# Usage
|
| 324 |
async def main():
|
| 325 |
-
results = await search_bible_async(
|
| 326 |
-
'love your neighbor',
|
| 327 |
-
testament='new',
|
| 328 |
-
limit=5
|
| 329 |
-
)
|
| 330 |
print(results)
|
| 331 |
|
| 332 |
asyncio.run(main())
|
|
@@ -336,16 +273,6 @@ asyncio.run(main())
|
|
| 336 |
|
| 337 |
### cURL
|
| 338 |
|
| 339 |
-
#### Basic Search
|
| 340 |
-
```bash
|
| 341 |
-
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 342 |
-
-H "Content-Type: application/json" \
|
| 343 |
-
-d '{
|
| 344 |
-
"query": "blessed are the peacemakers"
|
| 345 |
-
}'
|
| 346 |
-
```
|
| 347 |
-
|
| 348 |
-
#### Pretty Print with jq
|
| 349 |
```bash
|
| 350 |
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 351 |
-H "Content-Type: application/json" \
|
|
@@ -415,7 +342,7 @@ async function safeSearch(query) {
|
|
| 415 |
2. **Debounce** search queries to reduce API calls
|
| 416 |
3. **Implement pagination** for large result sets
|
| 417 |
4. **Use appropriate limits** - higher limits increase response time
|
| 418 |
-
5. **
|
| 419 |
|
| 420 |
### Rate Limiting
|
| 421 |
Currently no rate limiting is enforced, but please use responsibly:
|
|
|
|
| 65 |
|
| 66 |
**POST /search**
|
| 67 |
|
| 68 |
+
Perform semantic search over the entire Bible (both Old and New Testament).
|
| 69 |
|
| 70 |
#### Request Body
|
| 71 |
|
| 72 |
| Field | Type | Required | Description |
|
| 73 |
|-------|------|----------|-------------|
|
| 74 |
| `query` | string | Yes | Search query text (1-500 chars) |
|
|
|
|
|
|
|
| 75 |
| `limit` | integer | No | Number of results (1-100, default: 10) |
|
| 76 |
|
| 77 |
#### Response
|
|
|
|
| 93 |
}
|
| 94 |
```
|
| 95 |
|
| 96 |
+
#### Example
|
| 97 |
|
|
|
|
| 98 |
```bash
|
| 99 |
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 100 |
-H "Content-Type: application/json" \
|
|
|
|
| 104 |
}'
|
| 105 |
```
|
| 106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 107 |
---
|
| 108 |
|
| 109 |
## Integration Examples
|
|
|
|
| 112 |
|
| 113 |
#### Basic Fetch
|
| 114 |
```javascript
|
| 115 |
+
async function searchBible(query, limit = 10) {
|
| 116 |
const response = await fetch('https://dssjon-biblos-api.hf.space/search', {
|
| 117 |
method: 'POST',
|
| 118 |
headers: {
|
|
|
|
| 120 |
},
|
| 121 |
body: JSON.stringify({
|
| 122 |
query,
|
| 123 |
+
limit
|
| 124 |
})
|
| 125 |
})
|
| 126 |
|
|
|
|
| 132 |
}
|
| 133 |
|
| 134 |
// Usage
|
| 135 |
+
const results = await searchBible('love one another', 5)
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
console.log(results)
|
| 138 |
```
|
|
|
|
| 141 |
```typescript
|
| 142 |
import { useState, useCallback } from 'react'
|
| 143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
interface SearchResult {
|
| 145 |
book: string
|
| 146 |
chapter: number
|
|
|
|
| 155 |
|
| 156 |
const search = useCallback(async (
|
| 157 |
query: string,
|
| 158 |
+
limit: number = 10
|
| 159 |
): Promise<SearchResult[]> => {
|
| 160 |
setLoading(true)
|
| 161 |
setError(null)
|
|
|
|
| 164 |
const response = await fetch('https://dssjon-biblos-api.hf.space/search', {
|
| 165 |
method: 'POST',
|
| 166 |
headers: { 'Content-Type': 'application/json' },
|
| 167 |
+
body: JSON.stringify({ query, limit })
|
| 168 |
})
|
| 169 |
|
| 170 |
if (!response.ok) {
|
|
|
|
| 191 |
const [results, setResults] = useState([])
|
| 192 |
|
| 193 |
const handleSearch = async (query: string) => {
|
| 194 |
+
const results = await search(query, 10)
|
| 195 |
setResults(results)
|
| 196 |
}
|
| 197 |
|
|
|
|
| 209 |
```python
|
| 210 |
import requests
|
| 211 |
|
| 212 |
+
def search_bible(query, limit=10):
|
| 213 |
"""
|
| 214 |
Search the Bible using semantic search
|
| 215 |
|
| 216 |
Args:
|
| 217 |
query: Search query text
|
|
|
|
|
|
|
| 218 |
limit: Number of results to return
|
| 219 |
|
| 220 |
Returns:
|
|
|
|
| 227 |
'limit': limit
|
| 228 |
}
|
| 229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 230 |
response = requests.post(url, json=payload)
|
| 231 |
response.raise_for_status()
|
| 232 |
|
|
|
|
| 235 |
# Usage
|
| 236 |
results = search_bible(
|
| 237 |
query='faith and works',
|
|
|
|
| 238 |
limit=5
|
| 239 |
)
|
| 240 |
|
|
|
|
| 250 |
import asyncio
|
| 251 |
import aiohttp
|
| 252 |
|
| 253 |
+
async def search_bible_async(query, limit=10):
|
| 254 |
"""Async version of Bible search"""
|
| 255 |
url = 'https://dssjon-biblos-api.hf.space/search'
|
| 256 |
|
| 257 |
+
payload = {'query': query, 'limit': limit}
|
| 258 |
|
| 259 |
async with aiohttp.ClientSession() as session:
|
| 260 |
async with session.post(url, json=payload) as response:
|
|
|
|
| 263 |
|
| 264 |
# Usage
|
| 265 |
async def main():
|
| 266 |
+
results = await search_bible_async('love your neighbor', limit=5)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 267 |
print(results)
|
| 268 |
|
| 269 |
asyncio.run(main())
|
|
|
|
| 273 |
|
| 274 |
### cURL
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
```bash
|
| 277 |
curl -X POST https://dssjon-biblos-api.hf.space/search \
|
| 278 |
-H "Content-Type: application/json" \
|
|
|
|
| 342 |
2. **Debounce** search queries to reduce API calls
|
| 343 |
3. **Implement pagination** for large result sets
|
| 344 |
4. **Use appropriate limits** - higher limits increase response time
|
| 345 |
+
5. **The API searches the entire Bible** (both Old and New Testament) for comprehensive results
|
| 346 |
|
| 347 |
### Rate Limiting
|
| 348 |
Currently no rate limiting is enforced, but please use responsibly:
|
README.md
CHANGED
|
@@ -16,7 +16,7 @@ Semantic search over the entire Bible using BGE-large embeddings. This API keeps
|
|
| 16 |
|
| 17 |
- β
Fast semantic search with BGE-large-en-v1.5 embeddings
|
| 18 |
- β
Model stays loaded in memory (no cold starts)
|
| 19 |
-
- β
|
| 20 |
- β
CORS enabled for easy integration
|
| 21 |
- β
RESTful JSON API with FastAPI
|
| 22 |
- β
Automatic API documentation at `/docs`
|
|
@@ -36,9 +36,7 @@ Perform semantic search
|
|
| 36 |
```json
|
| 37 |
{
|
| 38 |
"query": "What did Jesus say about love?",
|
| 39 |
-
"
|
| 40 |
-
"testament": "new", // Optional: "old" or "new"
|
| 41 |
-
"limit": 10 // Optional: results to return (1-100)
|
| 42 |
}
|
| 43 |
```
|
| 44 |
|
|
@@ -60,12 +58,6 @@ Perform semantic search
|
|
| 60 |
}
|
| 61 |
```
|
| 62 |
|
| 63 |
-
## Book Abbreviations
|
| 64 |
-
|
| 65 |
-
**Old Testament:** gen, exo, lev, num, deu, jos, jdg, rut, 1sa, 2sa, 1ki, 2ki, 1ch, 2ch, ezr, neh, est, job, psa, pro, ecc, sng, isa, jer, lam, ezk, dan, hos, jol, amo, oba, jon, mic, nam, hab, zep, hag, zec, mal
|
| 66 |
-
|
| 67 |
-
**New Testament:** mat, mrk, luk, jhn, act, rom, 1co, 2co, gal, eph, php, col, 1th, 2th, 1ti, 2ti, tit, phm, heb, jas, 1pe, 2pe, 1jn, 2jn, 3jn, jud, rev
|
| 68 |
-
|
| 69 |
## Quick Start
|
| 70 |
|
| 71 |
### Using cURL
|
|
@@ -74,7 +66,6 @@ curl -X POST https://dssjon-biblos-api.hf.space/search \
|
|
| 74 |
-H "Content-Type: application/json" \
|
| 75 |
-d '{
|
| 76 |
"query": "faith and works",
|
| 77 |
-
"testament": "new",
|
| 78 |
"limit": 5
|
| 79 |
}'
|
| 80 |
```
|
|
@@ -86,7 +77,6 @@ const response = await fetch('https://dssjon-biblos-api.hf.space/search', {
|
|
| 86 |
headers: { 'Content-Type': 'application/json' },
|
| 87 |
body: JSON.stringify({
|
| 88 |
query: 'faith and works',
|
| 89 |
-
testament: 'new',
|
| 90 |
limit: 5
|
| 91 |
})
|
| 92 |
})
|
|
@@ -103,7 +93,6 @@ response = requests.post(
|
|
| 103 |
'https://dssjon-biblos-api.hf.space/search',
|
| 104 |
json={
|
| 105 |
'query': 'faith and works',
|
| 106 |
-
'testament': 'new',
|
| 107 |
'limit': 5
|
| 108 |
}
|
| 109 |
)
|
|
|
|
| 16 |
|
| 17 |
- β
Fast semantic search with BGE-large-en-v1.5 embeddings
|
| 18 |
- β
Model stays loaded in memory (no cold starts)
|
| 19 |
+
- β
Searches entire Bible (Old and New Testament)
|
| 20 |
- β
CORS enabled for easy integration
|
| 21 |
- β
RESTful JSON API with FastAPI
|
| 22 |
- β
Automatic API documentation at `/docs`
|
|
|
|
| 36 |
```json
|
| 37 |
{
|
| 38 |
"query": "What did Jesus say about love?",
|
| 39 |
+
"limit": 10 // Optional: results to return (1-100, default: 10)
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
```
|
| 42 |
|
|
|
|
| 58 |
}
|
| 59 |
```
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
## Quick Start
|
| 62 |
|
| 63 |
### Using cURL
|
|
|
|
| 66 |
-H "Content-Type: application/json" \
|
| 67 |
-d '{
|
| 68 |
"query": "faith and works",
|
|
|
|
| 69 |
"limit": 5
|
| 70 |
}'
|
| 71 |
```
|
|
|
|
| 77 |
headers: { 'Content-Type': 'application/json' },
|
| 78 |
body: JSON.stringify({
|
| 79 |
query: 'faith and works',
|
|
|
|
| 80 |
limit: 5
|
| 81 |
})
|
| 82 |
})
|
|
|
|
| 93 |
'https://dssjon-biblos-api.hf.space/search',
|
| 94 |
json={
|
| 95 |
'query': 'faith and works',
|
|
|
|
| 96 |
'limit': 5
|
| 97 |
}
|
| 98 |
)
|
app.py
CHANGED
|
@@ -39,8 +39,6 @@ app.add_middleware(
|
|
| 39 |
# Request/Response models
|
| 40 |
class SearchRequest(BaseModel):
|
| 41 |
query: str = Field(..., description="Search query text", min_length=1, max_length=500)
|
| 42 |
-
books: Optional[List[str]] = Field(None, description="Filter by book abbreviations (e.g., ['gen', 'mat', 'jhn'])")
|
| 43 |
-
testament: Optional[str] = Field(None, description="Filter by testament: 'old' or 'new'")
|
| 44 |
limit: int = Field(10, description="Number of results to return", ge=1, le=100)
|
| 45 |
|
| 46 |
class SearchResult(BaseModel):
|
|
@@ -202,11 +200,9 @@ async def health_check():
|
|
| 202 |
@app.post("/search", response_model=SearchResponse)
|
| 203 |
async def search(request: SearchRequest):
|
| 204 |
"""
|
| 205 |
-
Perform semantic search over Bible
|
| 206 |
|
| 207 |
- **query**: The search query text
|
| 208 |
-
- **books**: Optional list of book abbreviations to search within
|
| 209 |
-
- **testament**: Optional filter by 'old' or 'new' testament
|
| 210 |
- **limit**: Number of results to return (1-100)
|
| 211 |
"""
|
| 212 |
import time
|
|
@@ -225,25 +221,8 @@ async def search(request: SearchRequest):
|
|
| 225 |
logger.info(f"Generating embedding for query: {request.query[:50]}...")
|
| 226 |
query_embedding = generate_embedding(request.query)
|
| 227 |
|
| 228 |
-
#
|
| 229 |
-
books_to_search =
|
| 230 |
-
if request.books:
|
| 231 |
-
# Use specified books
|
| 232 |
-
books_to_search = [b.lower() for b in request.books if b.lower() in bible_embeddings]
|
| 233 |
-
elif request.testament:
|
| 234 |
-
# Filter by testament
|
| 235 |
-
if request.testament.lower() == "old":
|
| 236 |
-
books_to_search = [b for b in OLD_TESTAMENT_BOOKS if b in bible_embeddings]
|
| 237 |
-
elif request.testament.lower() == "new":
|
| 238 |
-
books_to_search = [b for b in NEW_TESTAMENT_BOOKS if b in bible_embeddings]
|
| 239 |
-
else:
|
| 240 |
-
raise HTTPException(status_code=400, detail="testament must be 'old' or 'new'")
|
| 241 |
-
else:
|
| 242 |
-
# Search all books
|
| 243 |
-
books_to_search = list(bible_embeddings.keys())
|
| 244 |
-
|
| 245 |
-
if not books_to_search:
|
| 246 |
-
raise HTTPException(status_code=400, detail="No valid books to search")
|
| 247 |
|
| 248 |
# Collect all results
|
| 249 |
all_results = []
|
|
|
|
| 39 |
# Request/Response models
|
| 40 |
class SearchRequest(BaseModel):
|
| 41 |
query: str = Field(..., description="Search query text", min_length=1, max_length=500)
|
|
|
|
|
|
|
| 42 |
limit: int = Field(10, description="Number of results to return", ge=1, le=100)
|
| 43 |
|
| 44 |
class SearchResult(BaseModel):
|
|
|
|
| 200 |
@app.post("/search", response_model=SearchResponse)
|
| 201 |
async def search(request: SearchRequest):
|
| 202 |
"""
|
| 203 |
+
Perform semantic search over the entire Bible (both Old and New Testament)
|
| 204 |
|
| 205 |
- **query**: The search query text
|
|
|
|
|
|
|
| 206 |
- **limit**: Number of results to return (1-100)
|
| 207 |
"""
|
| 208 |
import time
|
|
|
|
| 221 |
logger.info(f"Generating embedding for query: {request.query[:50]}...")
|
| 222 |
query_embedding = generate_embedding(request.query)
|
| 223 |
|
| 224 |
+
# Search all books (both Old and New Testament)
|
| 225 |
+
books_to_search = list(bible_embeddings.keys())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
# Collect all results
|
| 228 |
all_results = []
|