content_processor / README_HF.md
satishsnv
updated readme
20929ce
|
Raw History Blame Contribute Delete
2.9 kB
---
title: Address Detection and Summarization API
emoji: πŸ πŸ“
colorFrom: blue
colorTo: green
sdk: docker
app_port: 7860
pinned: false
license: mit
---
# Address Detection and Summarization API
A FastAPI service that provides two main endpoints for AI-powered text processing:
## πŸš€ Features
- 🏠 **Address Detection**: Extracts and formats addresses from unstructured text
- πŸ“ **Text Summarization**: Creates concise summaries with sentiment analysis
- πŸ€– **OpenAI Integration**: Uses GPT-4 for natural language processing
- πŸ” **Secure**: API key required via `x-api-key` header
- πŸ“Š **Sentiment Analysis**: Returns sentiment label and score (-1.0 to 1.0)
## πŸ“‹ API Endpoints
### Root & Health
- `GET /` - API information
- `GET /health` - Health check
- `GET /docs` - Interactive API documentation
### Address Detection
`POST /address-detection`
Extract addresses from text content.
**Request:**
```json
{
"entity_urn": "unique_id",
"content": "Please send to 123 Main Street, New York, NY 10001"
}
```
**Headers:**
```
Content-Type: application/json
x-api-key: your_openai_api_key
```
### Text Summarization
`POST /summarize`
Generate summary with sentiment analysis.
**Request:**
```json
{
"entity_urn": "unique_id",
"content": "Your text content to summarize..."
}
```
## πŸ”§ Usage Examples
### Using curl:
```bash
# Address Detection
curl -X POST "https://your-space-name.hf.space/address-detection" \
-H "Content-Type: application/json" \
-H "x-api-key: your_openai_api_key" \
-d '{"entity_urn": "test", "content": "Send to 123 Main St, NYC"}'
# Summarization
curl -X POST "https://your-space-name.hf.space/summarize" \
-H "Content-Type: application/json" \
-H "x-api-key: your_openai_api_key" \
-d '{"entity_urn": "test", "content": "I love this product!"}'
```
### Response Format:
```json
{
"message": "success",
"result": "extracted_addresses || separated",
"action_type": "detect_address",
"entity_urn": "test",
"sentiment": null
}
```
For summarization, `sentiment` contains:
```json
{
"label": "positive",
"score": 0.8
}
```
## πŸ”‘ Authentication
You need an OpenAI API key to use this service:
1. Get your API key from [OpenAI Platform](https://platform.openai.com/)
2. Include it in the `x-api-key` header with each request
3. No registration required - just use your own key
## πŸ—οΈ Built With
- **FastAPI** 0.115.14 - Modern web framework
- **OpenAI** 1.92.1 - AI language models
- **Pydantic** 2.11.7 - Data validation
- **Python** 3.12 - Runtime
## πŸ“– Documentation
Visit `/docs` for interactive API documentation with request/response examples and testing interface.
## πŸ”’ Security & Privacy
- Your OpenAI API key is required for each request
- No API keys are stored on our servers
- All requests are processed in real-time
- No conversation history is retained