Spaces:
Running
Running
Update README.md
Browse files
README.md
CHANGED
|
@@ -34,5 +34,86 @@ We created this app to explore how LLMs can mimic traditional search engines by
|
|
| 34 |
### Try the Demo
|
| 35 |
Deployed on Hugging Face Spaces, you can test it at [https://codelion-llmsearchengine.hf.space](https://codelion-llmsearchengine.hf.space):
|
| 36 |
1. Open the URL in your browser.
|
| 37 |
-
2. Type a query (e.g
|
| 38 |
-
3. Browse the paginated results, styled like Google, using "Previous" and "Next" links.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
### Try the Demo
|
| 35 |
Deployed on Hugging Face Spaces, you can test it at [https://codelion-llmsearchengine.hf.space](https://codelion-llmsearchengine.hf.space):
|
| 36 |
1. Open the URL in your browser.
|
| 37 |
+
2. Type a query (e.g. "best Python libraries") in the search bar and press Enter or click "LLM Search".
|
| 38 |
+
3. Browse the paginated results, styled like Google, using "Previous" and "Next" links.
|
| 39 |
+
|
| 40 |
+
## Using It as an API
|
| 41 |
+
|
| 42 |
+
### API Endpoint
|
| 43 |
+
|
| 44 |
+
Your app doubles as an API when hosted on HF Spaces:
|
| 45 |
+
|
| 46 |
+
- **URL:** `https://codelion-llmsearchengine.hf.space/`
|
| 47 |
+
- **Method:** `GET`
|
| 48 |
+
- **Parameters:**
|
| 49 |
+
- `query`: The search query (e.g., `"best Python libraries"`).
|
| 50 |
+
- `page`: Page number (`1-3`, defaults to `1`).
|
| 51 |
+
|
| 52 |
+
### Example Request
|
| 53 |
+
|
| 54 |
+
```bash
|
| 55 |
+
curl "https://codelion-llmsearchengine.hf.space/?query=best+Python+libraries&page=1"
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
### Response
|
| 59 |
+
|
| 60 |
+
Returns **raw HTML** styled like a Google search results page.
|
| 61 |
+
|
| 62 |
+
---
|
| 63 |
+
|
| 64 |
+
## Integration
|
| 65 |
+
|
| 66 |
+
You can fetch results programmatically and render or parse the HTML:
|
| 67 |
+
|
| 68 |
+
```python
|
| 69 |
+
import requests
|
| 70 |
+
from urllib.parse import quote
|
| 71 |
+
|
| 72 |
+
query = "best Python libraries"
|
| 73 |
+
page = 1
|
| 74 |
+
url = f"https://codelion-llmsearchengine.hf.space/?query={quote(query)}&page={page}"
|
| 75 |
+
response = requests.get(url)
|
| 76 |
+
html_content = response.text # Render or process as needed
|
| 77 |
+
print(html_content)
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
---
|
| 81 |
+
|
| 82 |
+
## How It Works
|
| 83 |
+
|
| 84 |
+
1. **LLM Prompting**
|
| 85 |
+
- Queries trigger a prompt to the `"gemini-2.0-flash-lite"` model.
|
| 86 |
+
- Generates **30 results** in JSON format.
|
| 87 |
+
|
| 88 |
+
2. **Rendering**
|
| 89 |
+
- Flask converts results into a **Google-styled** HTML page.
|
| 90 |
+
- Includes a **search bar, results, and pagination**.
|
| 91 |
+
|
| 92 |
+
3. **Deployment**
|
| 93 |
+
- Runs via **Flask** and **Docker** on HF Spaces.
|
| 94 |
+
- Serves **dynamic pages** based on URL parameters.
|
| 95 |
+
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
## Setup Locally
|
| 99 |
+
|
| 100 |
+
### Install dependencies
|
| 101 |
+
|
| 102 |
+
```bash
|
| 103 |
+
pip install -r requirements.txt
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
### Set environment variables
|
| 107 |
+
|
| 108 |
+
```bash
|
| 109 |
+
export OPENAI_API_KEY="your-key"
|
| 110 |
+
export OPENAI_BASE_URL="your-url"
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### Run the app
|
| 114 |
+
|
| 115 |
+
```bash
|
| 116 |
+
python app.py
|
| 117 |
+
```
|
| 118 |
+
|
| 119 |
+
Visit `http://localhost:5000`
|