Maximofn commited on
Commit
6dace56
·
verified ·
1 Parent(s): f773f96

Create readme.md

Browse files
Files changed (1) hide show
  1. readme.md +94 -0
readme.md ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: GDG Aranjuez - Backend inference endpoints docker
3
+ emoji: 📊
4
+ colorFrom: yellow
5
+ colorTo: red
6
+ sdk: docker
7
+ pinned: false
8
+ license: apache-2.0
9
+ short_description: Creamos un backend con docker, langchain, fastapi e inferende endpoints
10
+ app_port: 7860
11
+ ---
12
+
13
+ # SmolLM2 Backend
14
+
15
+ This project implements a FastAPI API that uses LangChain and LangGraph to generate text with the Qwen2.5-72B-Instruct model from HuggingFace.
16
+
17
+ ## Configuration
18
+
19
+ ### In HuggingFace Spaces
20
+
21
+ This project is designed to run in HuggingFace Spaces. To configure it:
22
+
23
+ 1. Create a new Space in HuggingFace with SDK Docker
24
+ 2. Configure the `HUGGINGFACE_TOKEN` or `HF_TOKEN` environment variable in the Space configuration:
25
+ - Go to the "Settings" tab of your Space
26
+ - Scroll down to the "Repository secrets" section
27
+ - Add a new variable with the name `HUGGINGFACE_TOKEN` and your token as the value
28
+ - Save the changes
29
+
30
+ ### Local development
31
+
32
+ For local development:
33
+
34
+ 1. Clone this repository
35
+ 2. Create a `.env` file in the project root with your HuggingFace token:
36
+ ``
37
+ HUGGINGFACE_TOKEN=your_token_here
38
+ ``
39
+ 3. Install the dependencies:
40
+ ``
41
+ pip install -r requirements.txt
42
+ ``
43
+
44
+ ## Local execution
45
+
46
+ ``bash
47
+ uvicorn app:app --reload
48
+ ``
49
+
50
+ The API will be available at `http://localhost:8000`.
51
+
52
+ ## Endpoints
53
+
54
+ ### GET `/`
55
+
56
+ Welcome endpoint that returns a greeting message.
57
+
58
+ ### POST `/generate`
59
+
60
+ Endpoint to generate text using the language model.
61
+
62
+ **Request parameters:**
63
+ ``json
64
+ {
65
+ "query": "Your question here",
66
+ "thread_id": "optional_thread_identifier"
67
+ }
68
+ ``
69
+
70
+ **Response:**
71
+ ``json
72
+ {
73
+ "generated_text": "Generated text by the model",
74
+ "thread_id": "thread identifier"
75
+ }
76
+ ``
77
+
78
+ ## Docker
79
+
80
+ To run the application in a Docker container:
81
+
82
+ ``bash
83
+ # Build the image
84
+ docker build -t smollm2-backend .
85
+
86
+ # Run the container
87
+ docker run -p 8000:8000 --env-file .env smollm2-backend
88
+ ``
89
+
90
+ ## API documentation
91
+
92
+ The interactive API documentation is available at:
93
+ - Swagger UI: `http://localhost:8000/docs`
94
+ - ReDoc: `http://localhost:8000/redoc`