Skip to content

Commit 42244cb

Browse files
authored
Update README.md
1 parent 5a1bedb commit 42244cb

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

README.md

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,74 @@
11
# vector-embedding-api
2-
Flask API for generating text embeddings using OpenAI or sentence_transformers
2+
Flask server that allows users to generate text embeddings using OpenAI's "text-embedding-ada-002" model or the Sentence Transformers library. Text embeddings are dense vector representations of textual data that capture semantic information, making them useful for various natural language processing tasks.
3+
4+
## Features 🎯
5+
* POST endpoint access to text embedding models
6+
* sentence_transformers
7+
* OpenAI text-embedding-ada-002
8+
* Easy setup with configuration file
9+
* Simple integration with other applications
10+
11+
### Installation 💻
12+
To run this Flask server locally, follow the steps below:
13+
14+
**Clone the repository:** 📦
15+
```bash
16+
git clone https://github.com/your-username/text-embeddings-server.git
17+
cd text-embeddings-server
18+
```
19+
20+
**Set up a virtual environment (optional but recommended):** 🐍
21+
```bash
22+
python3 -m venv venv
23+
source venv/bin/activate
24+
```
25+
26+
**Install the required dependencies:** 🛠️
27+
```bash
28+
pip install -r requirements.txt
29+
```
30+
31+
32+
### Usage
33+
Before running the server, make sure you have obtained an API key from OpenAI to use their "text-embedding-ada-002" model. Additionally, you need to specify the Sentence Transformers model you want to use in the server.conf file.
34+
35+
**Modify the server.conf configuration file:** ⚙️
36+
```ini
37+
[main]
38+
openai_api_key = YOUR_OPENAI_API_KEY
39+
sent_transformers_model = YOUR_SENTENCE_TRANSFORMERS_MODEL_NAME
40+
```
41+
42+
**Start the Flask server:** 🚀
43+
```
44+
python server.py
45+
```
46+
47+
The server should now be running on http://127.0.0.1:5000/.
48+
49+
50+
### API Endpoints 🌐
51+
The server provides the following endpoint:
52+
53+
#### POST /submit
54+
Submit text to be converted to embeddings.
55+
The default is to use the sentence transformers model.
56+
Setting the `ada` field to True will use the OpenAI model
57+
58+
59+
**Example Request:**
60+
```bash
61+
curl -X POST -H "Content-Type: application/json" -d '{"text": "This is an example text.", "ada": true}' http://127.0.0.1:5000/submit
62+
```
63+
64+
**Example Response:**
65+
66+
```json
67+
{
68+
"embedding": [0.123, 0.456, ..., 0.789],
69+
"status": "success"
70+
}
71+
```
72+
73+
### Error Handling ⚠️
74+
The server responds with appropriate error messages if there are any issues with the request or generating embeddings.

0 commit comments

Comments
 (0)