MarcosFRGames commited on
Commit
1760240
·
verified ·
1 Parent(s): eeedf36

Delete README (4).md

Browse files
Files changed (1) hide show
  1. README (4).md +0 -191
README (4).md DELETED
@@ -1,191 +0,0 @@
1
- ---
2
- title: Ollama API Space
3
- emoji: 🚀
4
- colorFrom: blue
5
- colorTo: purple
6
- sdk: docker
7
- app_port: 7860
8
- ---
9
-
10
- # 🚀 Ollama API Space
11
-
12
- A Hugging Face Space that provides a REST API interface for Ollama models, allowing you to run local LLMs through a web API.
13
-
14
- ## 🌟 Features
15
-
16
- - **Model Management**: List and pull Ollama models
17
- - **Text Generation**: Generate text using any available Ollama model
18
- - **REST API**: Simple HTTP endpoints for easy integration
19
- - **Health Monitoring**: Built-in health checks and status monitoring
20
- - **OpenWebUI Integration**: Compatible with OpenWebUI for a full chat interface
21
-
22
- ## 🚀 Quick Start
23
-
24
- ### 1. Deploy to Hugging Face Spaces
25
-
26
- 1. Fork this repository or create a new Space
27
- 2. Upload these files to your Space
28
- 3. **No environment variables needed** - Ollama runs inside the Space!
29
- 4. Wait for the build to complete (may take 10-15 minutes due to Ollama installation)
30
-
31
- ### 2. Local Development
32
-
33
- ```bash
34
- # Clone the repository
35
- git clone <your-repo-url>
36
- cd ollama-space
37
-
38
- # Install dependencies
39
- pip install -r requirements.txt
40
-
41
- # Install Ollama locally
42
- curl -fsSL https://ollama.ai/install.sh | sh
43
-
44
- # Start Ollama in another terminal
45
- ollama serve
46
-
47
- # Run the application
48
- python app.py
49
- ```
50
-
51
- ## 📡 API Endpoints
52
-
53
- ### GET `/api/models`
54
- List all available Ollama models.
55
-
56
- **Response:**
57
- ```json
58
- {
59
- "status": "success",
60
- "models": ["llama2", "codellama", "neural-chat"],
61
- "count": 3
62
- }
63
- ```
64
-
65
- ### POST `/api/models/pull`
66
- Pull a model from Ollama.
67
-
68
- **Request Body:**
69
- ```json
70
- {
71
- "name": "llama2"
72
- }
73
- ```
74
-
75
- **Response:**
76
- ```json
77
- {
78
- "status": "success",
79
- "model": "llama2"
80
- }
81
- ```
82
-
83
- ### POST `/api/generate`
84
- Generate text using a model.
85
-
86
- **Request Body:**
87
- ```json
88
- {
89
- "model": "llama2",
90
- "prompt": "Hello, how are you?",
91
- "temperature": 0.7,
92
- "max_tokens": 100
93
- }
94
- ```
95
-
96
- **Response:**
97
- ```json
98
- {
99
- "status": "success",
100
- "response": "Hello! I'm doing well, thank you for asking...",
101
- "model": "llama2",
102
- "usage": {
103
- "prompt_tokens": 7,
104
- "completion_tokens": 15,
105
- "total_tokens": 22
106
- }
107
- }
108
- ```
109
-
110
- ### GET `/health`
111
- Health check endpoint.
112
-
113
- **Response:**
114
- ```json
115
- {
116
- "status": "healthy",
117
- "ollama_connection": "connected",
118
- "available_models": 3
119
- }
120
- ```
121
-
122
- ## 🔧 Configuration
123
-
124
- ### Environment Variables
125
-
126
- - `OLLAMA_BASE_URL`: URL to your Ollama instance (default: `http://localhost:11434` - **Ollama runs inside this Space!**)
127
- - `MODELS_DIR`: Directory for storing models (default: `/models`)
128
- - `ALLOWED_MODELS`: Comma-separated list of allowed models (default: all models)
129
-
130
- **Note**: This Space now includes Ollama installed directly inside it, so you don't need an external Ollama instance!
131
-
132
- ### Supported Models
133
-
134
- By default, the following models are allowed:
135
- - `llama2`
136
- - `llama2:13b`
137
- - `llama2:70b`
138
- - `codellama`
139
- - `neural-chat`
140
-
141
- You can customize this list by setting the `ALLOWED_MODELS` environment variable.
142
-
143
- ## 🌐 Integration with OpenWebUI
144
-
145
- This Space is designed to work seamlessly with OpenWebUI. You can:
146
-
147
- 1. Use this Space as a backend API for OpenWebUI
148
- 2. Configure OpenWebUI to connect to this Space's endpoints
149
- 3. Enjoy a full chat interface with your local Ollama models
150
-
151
- ## 🐳 Docker Support
152
-
153
- The Space includes a Dockerfile for containerized deployment:
154
-
155
- ```bash
156
- # Build the image
157
- docker build -t ollama-space .
158
-
159
- # Run the container
160
- docker run -p 7860:7860 -e OLLAMA_BASE_URL=http://host.docker.internal:11434 ollama-space
161
- ```
162
-
163
- ## 🔒 Security Considerations
164
-
165
- - The Space only allows access to models specified in `ALLOWED_MODELS`
166
- - All API endpoints are publicly accessible (consider adding authentication for production use)
167
- - The Space connects to your Ollama instance - ensure proper network security
168
-
169
- ## 🚨 Troubleshooting
170
-
171
- ### Common Issues
172
-
173
- 1. **Connection to Ollama failed**: Check if Ollama is running and accessible
174
- 2. **Model not found**: Ensure the model is available in your Ollama instance
175
- 3. **Timeout errors**: Large models may take time to load - increase timeout values
176
-
177
- ### Health Check
178
-
179
- Use the `/health` endpoint to monitor the Space's status and Ollama connection.
180
-
181
- ## 📝 License
182
-
183
- This project is open source and available under the MIT License.
184
-
185
- ## 🤝 Contributing
186
-
187
- Contributions are welcome! Please feel free to submit a Pull Request.
188
-
189
- ## 📞 Support
190
-
191
- If you encounter any issues or have questions, please open an issue on the repository.