File size: 2,376 Bytes
315d075
38cfa26
315d075
38cfa26
315d075
38cfa26
315d075
38cfa26
315d075
38cfa26
315d075
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# DeepInfra-Wrapper

DeepInfra-Wrapper is a Python Flask project designed to provide a convenient and free interface for utilizing the DeepInfra API through reverse-engineering. It serves as a local and global server host, allowing users to interact with the DeepInfra chat completion models using Python requests.

## Features

- **Local and Global Server**: Choose between a local server or utilize a global server with Cloudflare integration for enhanced performance.

- **Chat Completion**: Easily generate chat completions by sending messages to the DeepInfra API.

- **Model Selection**: Access a variety of models for different use cases.

- **Streaming Support**: Enable real-time streaming for dynamic chat interactions.

## Getting Started

### Prerequisites

- Python 3.6 or higher
- Flask
- Flask-CORS
- Flask-Cloudflared
- Requests
- Fake User Agent

### Installation

1. Clone the repository:

   ```bash
   git clone https://github.com/Recentaly/DeepInfra-Wrapper.git
   ```

2. Install dependencies:

   ```bash
   pip install -r requirements.txt
   ```

3. Run the Flask application:

   ```bash
   python app.py
   ```

## Configuration

Adjust the configuration settings in the `assets/config.json` file to customize your DeepInfra-Wrapper experience.

```json
{
    "use_global": true
}
```

## Usage

### Chat Completion

Send a POST request to `/chat/completions` with the following JSON payload (messages must be in OpenAI format):

```json
{
    "messages": [{"role": "user", "content": "Hello, World!"}],
    "model": "meta-llama/Llama-2-70b-chat-hf",
    "max_tokens": 150,
    "top_p": 1,
    "stream": true
}
```

### Get Models

Retrieve the available models by sending a GET request to `/models`.

### Check API Status

Verify the API status by accessing the root route `/`.

## Error Handling

The API gracefully handles errors, such as forbidden requests, providing meaningful error messages.

## Google Colab

The server is also usable on [This Google Colab Link](https://colab.research.google.com/drive/15sQ6sjZJYUincL3otypxfH96aCfLQ7HZ?usp=sharing)

## License

This project is licensed under the [MIT License](LICENSE).

## Acknowledgments

- Special thanks to the DeepInfra team for providing the chat completion models.

## Contact

For issues and inquiries, please open an [issue](https://github.com/Recentaly/DeepInfra-Wrapper/issues).