tommytracx commited on
Commit
6b05f97
·
verified ·
1 Parent(s): e05df0a

Create README-Spaces.md

Browse files
Files changed (1) hide show
  1. README-Spaces.md +100 -0
README-Spaces.md ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # GainEnergy/OGAI-24B API
2
+
3
+ This repository contains the code to deploy the GainEnergy/OGAI-24B model as an API service on Hugging Face Spaces.
4
+
5
+ ## Features
6
+
7
+ - Full REST API with FastAPI
8
+ - Streaming support
9
+ - Configurable generation parameters
10
+ - Docker support for easy deployment
11
+ - Chat-formatted responses following the message role format (system, user, assistant)
12
+
13
+ ## Deployment on Hugging Face Spaces
14
+
15
+ 1. Create a new Space on Hugging Face:
16
+ - Go to https://huggingface.co/spaces
17
+ - Click "Create new Space"
18
+ - Choose a name for your Space
19
+ - Select "Docker" as Space SDK
20
+ - Select "GPU" as Hardware (A10G or better recommended)
21
+
22
+ 2. Upload the following files to your Space:
23
+ - `app.py`
24
+ - `requirements.txt`
25
+ - `Dockerfile`
26
+ - `.gitattributes` (optional, for handling large files)
27
+
28
+ 3. The Space will automatically build and deploy the Docker image.
29
+
30
+ ## Environment Variables
31
+
32
+ You can configure the following environment variables in your Hugging Face Space:
33
+
34
+ - `MODEL_ID`: The model ID to load (default: "GainEnergy/OGAI-24B")
35
+ - `DEFAULT_MAX_LENGTH`: Default maximum length for generation (default: 2048)
36
+ - `DEFAULT_TEMPERATURE`: Default temperature for generation (default: 0.7)
37
+
38
+ ## API Usage
39
+
40
+ ### Generate Text
41
+
42
+ **Endpoint**: `POST /generate`
43
+
44
+ **Request Body**:
45
+ ```json
46
+ {
47
+ "messages": [
48
+ {
49
+ "role": "system",
50
+ "content": "You are an assistant specialized in oil and gas engineering."
51
+ },
52
+ {
53
+ "role": "user",
54
+ "content": "Explain the principles of reservoir simulation."
55
+ }
56
+ ],
57
+ "temperature": 0.7,
58
+ "max_tokens": 2048,
59
+ "top_p": 0.95,
60
+ "top_k": 50,
61
+ "stream": false
62
+ }
63
+ ```
64
+
65
+ **Response**:
66
+ ```json
67
+ {
68
+ "generated_text": "Reservoir simulation is a computational method used to predict the flow of fluids (oil, gas, and water) through porous media over time..."
69
+ }
70
+ ```
71
+
72
+ ### Stream Generated Text
73
+
74
+ **Endpoint**: `POST /generate_stream`
75
+
76
+ This endpoint supports Server-Sent Events (SSE) for streaming responses. Set `"stream": true` in your request body.
77
+
78
+ ## Local Development
79
+
80
+ 1. Clone the repository:
81
+ ```bash
82
+ git clone https://huggingface.co/spaces/your-username/your-space-name
83
+ cd your-space-name
84
+ ```
85
+
86
+ 2. Install dependencies:
87
+ ```bash
88
+ pip install -r requirements.txt
89
+ ```
90
+
91
+ 3. Run the application:
92
+ ```bash
93
+ python app.py
94
+ ```
95
+
96
+ 4. The API will be available at http://localhost:7860
97
+
98
+ ## License
99
+
100
+ This project is licensed under the Apache 2.0 License - see the original model card for details.