File size: 2,699 Bytes
b220449
 
 
 
 
 
 
 
 
ee9af6d
 
 
 
 
00d5a9b
ee9af6d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
105
106
107
---
title: AI News Agent
emoji: 👀
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
---

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

The AI News Agent is a Flask application deployed on Hugging Face Spaces via Docker. This application provides multiple endpoints that allow users to search, query, and analyze news articles based on various parameters such as keywords, tone, and policy changes.

## Endpoints
Base url: https://oxbridge-economics-AI-News-Agent.hf.space/

### `/search`

**Purpose**: Search for articles based on category and title keywords.

**Request Example**:
```json
POST /search
Content-Type: application/json

{
  "titles": ["economy", "finance"],
  "categories": ["business", "technology"]
}
```

### `/query`

**Purpose**: Retrieve detailed responses to queries about specific articles identified by article IDs.

**Request Example**:
```json
POST /query
Content-Type: application/json

{
  "ids": ["article1_id", "article2_id"],
  "query": "What is the impact of the new economic policy?"
}
```

### `/tone`

**Purpose**: Compare the tone between two articles.

**Request Example**:
```json
POST /tone
Content-Type: application/json

{
  "source": "internal or external",
  "article1": "article1_id or article1 content",
  "article2": "article2_id or article2 content"
}
```

### `/compare`

**Purpose**: Compare policy changes between two articles.

**Request Example**:
```json
POST /tone
Content-Type: application/json

{
  "source": "internal or external",
  "article1": "article1_id or article1 content",
  "article2": "article2_id or article2 content"
}
```

### `/keyword`

**Purpose**: Count how many times a specific keyword appears in two different articles.

**Request Example**:
```json
POST /tone
Content-Type: application/json

{
  "source": "internal or external",
  "keyword": "keyword to search",
  "article1": "article1_id or article1 content",
  "article2": "article2_id or article2 content"
}
```

## Structure

- **`/routes`**: Contains `main.py` which configures the routes for the Flask application.
- **`/controllers`**:
  - `article_search_service.py`: Functions to search for articles in the database.
  - `article_query_service.py`: Functions to query an LLM for information about articles.
  - `article_comparison_service.py`: Functions to compare tone, policy, and count keywords in articles.

## Deployment

This application is deployed on [Hugging Face Spaces](https://huggingface.co/spaces/Oxbridge-Economics/AI-News-Agent?logs=container). The deployment process is managed through Docker, configured in the Dockerfile within this repository, and automated by GitHub Actions.