chatmock 1.36__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chatmock-1.36/LICENSE +21 -0
- chatmock-1.36/PKG-INFO +194 -0
- chatmock-1.36/README.md +172 -0
- chatmock-1.36/chatmock/__init__.py +5 -0
- chatmock-1.36/chatmock/app.py +50 -0
- chatmock-1.36/chatmock/cli.py +416 -0
- chatmock-1.36/chatmock/config.py +48 -0
- chatmock-1.36/chatmock/http.py +24 -0
- chatmock-1.36/chatmock/limits.py +200 -0
- chatmock-1.36/chatmock/model_registry.py +183 -0
- chatmock-1.36/chatmock/models.py +26 -0
- chatmock-1.36/chatmock/oauth.py +340 -0
- chatmock-1.36/chatmock/prompt.md +326 -0
- chatmock-1.36/chatmock/prompt_gpt5_codex.md +100 -0
- chatmock-1.36/chatmock/reasoning.py +79 -0
- chatmock-1.36/chatmock/routes_ollama.py +573 -0
- chatmock-1.36/chatmock/routes_openai.py +541 -0
- chatmock-1.36/chatmock/session.py +89 -0
- chatmock-1.36/chatmock/transform.py +149 -0
- chatmock-1.36/chatmock/upstream.py +115 -0
- chatmock-1.36/chatmock/utils.py +874 -0
- chatmock-1.36/chatmock/version.py +4 -0
- chatmock-1.36/chatmock.egg-info/PKG-INFO +194 -0
- chatmock-1.36/chatmock.egg-info/SOURCES.txt +30 -0
- chatmock-1.36/chatmock.egg-info/dependency_links.txt +1 -0
- chatmock-1.36/chatmock.egg-info/entry_points.txt +2 -0
- chatmock-1.36/chatmock.egg-info/requires.txt +15 -0
- chatmock-1.36/chatmock.egg-info/top_level.txt +1 -0
- chatmock-1.36/pyproject.toml +40 -0
- chatmock-1.36/setup.cfg +4 -0
- chatmock-1.36/tests/test_models.py +33 -0
- chatmock-1.36/tests/test_routes.py +86 -0
chatmock-1.36/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Game_Time
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
chatmock-1.36/PKG-INFO
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: chatmock
|
|
3
|
+
Version: 1.36
|
|
4
|
+
Requires-Python: >=3.11
|
|
5
|
+
Description-Content-Type: text/markdown
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Dist: blinker==1.9.0
|
|
8
|
+
Requires-Dist: certifi==2025.8.3
|
|
9
|
+
Requires-Dist: flask==3.1.1
|
|
10
|
+
Requires-Dist: idna==3.10
|
|
11
|
+
Requires-Dist: itsdangerous==2.2.0
|
|
12
|
+
Requires-Dist: jinja2==3.1.6
|
|
13
|
+
Requires-Dist: markupsafe==3.0.2
|
|
14
|
+
Requires-Dist: requests==2.32.5
|
|
15
|
+
Requires-Dist: urllib3==2.5.0
|
|
16
|
+
Requires-Dist: werkzeug==3.1.3
|
|
17
|
+
Provides-Extra: gui
|
|
18
|
+
Requires-Dist: Pillow==11.3.0; extra == "gui"
|
|
19
|
+
Requires-Dist: PyInstaller==6.16.0; extra == "gui"
|
|
20
|
+
Requires-Dist: PySide6==6.9.2; extra == "gui"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
<div align="center">
|
|
24
|
+
<h1>ChatMock
|
|
25
|
+
<div align="center">
|
|
26
|
+
<a href="https://github.com/RayBytes/ChatMock/stargazers"><img src="https://img.shields.io/github/stars/RayBytes/ChatMock" alt="Stars Badge"/></a>
|
|
27
|
+
<a href="https://github.com/RayBytes/ChatMock/network/members"><img src="https://img.shields.io/github/forks/RayBytes/ChatMock" alt="Forks Badge"/></a>
|
|
28
|
+
<a href="https://github.com/RayBytes/ChatMock/pulls"><img src="https://img.shields.io/github/issues-pr/RayBytes/ChatMock" alt="Pull Requests Badge"/></a>
|
|
29
|
+
<a href="https://github.com/RayBytes/ChatMock/issues"><img src="https://img.shields.io/github/issues/RayBytes/ChatMock" alt="Issues Badge"/></a>
|
|
30
|
+
<a href="https://github.com/RayBytes/ChatMock/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/RayBytes/ChatMock?color=2b9348"></a>
|
|
31
|
+
<a href="https://github.com/RayBytes/ChatMock/blob/master/LICENSE"><img src="https://img.shields.io/github/license/RayBytes/ChatMock?color=2b9348" alt="License Badge"/></a>
|
|
32
|
+
</div>
|
|
33
|
+
</h1>
|
|
34
|
+
|
|
35
|
+
<p><b>OpenAI & Ollama compatible API powered by your ChatGPT plan.</b></p>
|
|
36
|
+
<p>Use your ChatGPT Plus/Pro account to call OpenAI models from code or alternate chat UIs.</p>
|
|
37
|
+
<br>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
## What It Does
|
|
41
|
+
|
|
42
|
+
ChatMock runs a local server that creates an OpenAI/Ollama compatible API, and requests are then fulfilled using your authenticated ChatGPT login with the oauth client of Codex, OpenAI's coding CLI tool. This allows you to use GPT-5, GPT-5-Codex, and other models right through your OpenAI account, without requiring an api key. You are then able to use it in other chat apps or other coding tools. <br>
|
|
43
|
+
This does require a paid ChatGPT account.
|
|
44
|
+
|
|
45
|
+
## Quickstart
|
|
46
|
+
|
|
47
|
+
### Homebrew
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
brew tap RayBytes/chatmock
|
|
51
|
+
brew install chatmock
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### CLI
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pipx install chatmock
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### GUI
|
|
61
|
+
|
|
62
|
+
If you're on **macOS** or **Windows**, you can download the GUI app from the [GitHub releases](https://github.com/RayBytes/ChatMock/releases).
|
|
63
|
+
|
|
64
|
+
### Python
|
|
65
|
+
If you wish to just simply run this as a python flask server, you are also freely welcome too.
|
|
66
|
+
|
|
67
|
+
Clone or download this repository, then cd into the project directory. Then follow the instrunctions listed below.
|
|
68
|
+
|
|
69
|
+
1. Sign in with your ChatGPT account and follow the prompts
|
|
70
|
+
```bash
|
|
71
|
+
python chatmock.py login
|
|
72
|
+
```
|
|
73
|
+
You can make sure this worked by running `python chatmock.py info`
|
|
74
|
+
|
|
75
|
+
2. After the login completes successfully, you can just simply start the local server
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
python chatmock.py serve
|
|
79
|
+
```
|
|
80
|
+
Then, you can simply use the address and port as the baseURL as you require (http://127.0.0.1:8000 by default)
|
|
81
|
+
|
|
82
|
+
**Reminder:** When setting a baseURL in other applications, make you sure you include /v1/ at the end of the URL if you're using this as a OpenAI compatible endpoint (e.g http://127.0.0.1:8000/v1)
|
|
83
|
+
|
|
84
|
+
### Docker
|
|
85
|
+
|
|
86
|
+
Read [the docker instrunctions here](https://github.com/RayBytes/ChatMock/blob/main/DOCKER.md)
|
|
87
|
+
|
|
88
|
+
# Examples
|
|
89
|
+
|
|
90
|
+
### Python
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from openai import OpenAI
|
|
94
|
+
|
|
95
|
+
client = OpenAI(
|
|
96
|
+
base_url="http://127.0.0.1:8000/v1",
|
|
97
|
+
api_key="key" # ignored
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
resp = client.chat.completions.create(
|
|
101
|
+
model="gpt-5.4",
|
|
102
|
+
messages=[{"role": "user", "content": "hello world"}]
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
print(resp.choices[0].message.content)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### curl
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
curl http://127.0.0.1:8000/v1/chat/completions \
|
|
112
|
+
-H "Authorization: Bearer key" \
|
|
113
|
+
-H "Content-Type: application/json" \
|
|
114
|
+
-d '{
|
|
115
|
+
"model": "gpt-5.4",
|
|
116
|
+
"messages": [{"role":"user","content":"hello world"}]
|
|
117
|
+
}'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
# What's supported
|
|
121
|
+
|
|
122
|
+
- Tool/Function calling
|
|
123
|
+
- Vision/Image understanding
|
|
124
|
+
- Thinking summaries (through thinking tags)
|
|
125
|
+
- Thinking effort
|
|
126
|
+
|
|
127
|
+
## Notes & Limits
|
|
128
|
+
|
|
129
|
+
- Requires an active, paid ChatGPT account.
|
|
130
|
+
- Some context length might be taken up by internal instructions (but they dont seem to degrade the model)
|
|
131
|
+
- Use responsibly and at your own risk. This project is not affiliated with OpenAI, and is a educational exercise.
|
|
132
|
+
|
|
133
|
+
# Supported models
|
|
134
|
+
- `gpt-5.4`
|
|
135
|
+
- `gpt-5.2`
|
|
136
|
+
- `gpt-5.1`
|
|
137
|
+
- `gpt-5`
|
|
138
|
+
- `gpt-5.3-codex`
|
|
139
|
+
- `gpt-5-codex`
|
|
140
|
+
- `gpt-5.2-codex`
|
|
141
|
+
- `gpt-5.1-codex`
|
|
142
|
+
- `gpt-5.1-codex-max`
|
|
143
|
+
- `gpt-5.1-codex-mini`
|
|
144
|
+
- `codex-mini`
|
|
145
|
+
|
|
146
|
+
# Customisation / Configuration
|
|
147
|
+
|
|
148
|
+
### Thinking effort
|
|
149
|
+
|
|
150
|
+
- `--reasoning-effort` (choice of none,minimal,low,medium,high,xhigh)<br>
|
|
151
|
+
GPT-5 has a configurable amount of "effort" it can put into thinking, which may cause it to take more time for a response to return, but may overall give a smarter answer. Applying this parameter after `serve` forces the server to use this reasoning effort by default, unless overrided by the API request with a different effort set. The default reasoning effort without setting this parameter is `medium`.<br>
|
|
152
|
+
The `gpt-5.1` family (including codex) supports `low`, `medium`, and `high` while `gpt-5.1-codex-max` adds `xhigh`. The `gpt-5.2` and `gpt-5.3` families (including codex) support `low`, `medium`, `high`, and `xhigh`. GPT-5.4 supports `none`, `low`, `medium`, `high`, and `xhigh`.
|
|
153
|
+
|
|
154
|
+
### Thinking summaries
|
|
155
|
+
|
|
156
|
+
- `--reasoning-summary` (choice of auto,concise,detailed,none)<br>
|
|
157
|
+
Models like GPT-5 do not return raw thinking content, but instead return thinking summaries. These can also be customised by you.
|
|
158
|
+
|
|
159
|
+
### OpenAI Tools
|
|
160
|
+
|
|
161
|
+
- `--enable-web-search`<br>
|
|
162
|
+
You can also access OpenAI tools through this project. Currently, only web search is available.
|
|
163
|
+
You can enable it by starting the server with this parameter, which will allow OpenAI to determine when a request requires a web search, or you can use the following parameters during a request to the API to enable web search:
|
|
164
|
+
<br><br>
|
|
165
|
+
`responses_tools`: supports `[{"type":"web_search"}]` / `{ "type": "web_search_preview" }`<br>
|
|
166
|
+
`responses_tool_choice`: `"auto"` or `"none"`
|
|
167
|
+
|
|
168
|
+
#### Example usage
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"model": "gpt-5.4",
|
|
172
|
+
"messages": [{"role":"user","content":"Find current METAR rules"}],
|
|
173
|
+
"stream": true,
|
|
174
|
+
"responses_tools": [{"type": "web_search"}],
|
|
175
|
+
"responses_tool_choice": "auto"
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Expose reasoning models
|
|
180
|
+
|
|
181
|
+
- `--expose-reasoning-models`<br>
|
|
182
|
+
If your preferred app doesn’t support selecting reasoning effort, or you just want a simpler approach, this parameter exposes each reasoning level as a separate, queryable model. Each reasoning level also appears individually under /v1/models, so model pickers in your favorite chat apps will list all reasoning options as distinct models you can switch between.
|
|
183
|
+
|
|
184
|
+
## Notes
|
|
185
|
+
If you wish to have the fastest responses, I'd recommend setting `--reasoning-effort` to low, and `--reasoning-summary` to none. <br>
|
|
186
|
+
All parameters and choices can be seen by sending `python chatmock.py serve --h`<br>
|
|
187
|
+
The context size of this route is also larger than what you get access to in the regular ChatGPT app.<br>
|
|
188
|
+
|
|
189
|
+
When the model returns a thinking summary, the model will send back thinking tags to make it compatible with chat apps. **If you don't like this behavior, you can instead set `--reasoning-compat` to legacy, and reasoning will be set in the reasoning tag instead of being returned in the actual response text.**
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
## Star History
|
|
193
|
+
|
|
194
|
+
[](https://www.star-history.com/#RayBytes/ChatMock&Timeline)
|
chatmock-1.36/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>ChatMock
|
|
3
|
+
<div align="center">
|
|
4
|
+
<a href="https://github.com/RayBytes/ChatMock/stargazers"><img src="https://img.shields.io/github/stars/RayBytes/ChatMock" alt="Stars Badge"/></a>
|
|
5
|
+
<a href="https://github.com/RayBytes/ChatMock/network/members"><img src="https://img.shields.io/github/forks/RayBytes/ChatMock" alt="Forks Badge"/></a>
|
|
6
|
+
<a href="https://github.com/RayBytes/ChatMock/pulls"><img src="https://img.shields.io/github/issues-pr/RayBytes/ChatMock" alt="Pull Requests Badge"/></a>
|
|
7
|
+
<a href="https://github.com/RayBytes/ChatMock/issues"><img src="https://img.shields.io/github/issues/RayBytes/ChatMock" alt="Issues Badge"/></a>
|
|
8
|
+
<a href="https://github.com/RayBytes/ChatMock/graphs/contributors"><img alt="GitHub contributors" src="https://img.shields.io/github/contributors/RayBytes/ChatMock?color=2b9348"></a>
|
|
9
|
+
<a href="https://github.com/RayBytes/ChatMock/blob/master/LICENSE"><img src="https://img.shields.io/github/license/RayBytes/ChatMock?color=2b9348" alt="License Badge"/></a>
|
|
10
|
+
</div>
|
|
11
|
+
</h1>
|
|
12
|
+
|
|
13
|
+
<p><b>OpenAI & Ollama compatible API powered by your ChatGPT plan.</b></p>
|
|
14
|
+
<p>Use your ChatGPT Plus/Pro account to call OpenAI models from code or alternate chat UIs.</p>
|
|
15
|
+
<br>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
## What It Does
|
|
19
|
+
|
|
20
|
+
ChatMock runs a local server that creates an OpenAI/Ollama compatible API, and requests are then fulfilled using your authenticated ChatGPT login with the oauth client of Codex, OpenAI's coding CLI tool. This allows you to use GPT-5, GPT-5-Codex, and other models right through your OpenAI account, without requiring an api key. You are then able to use it in other chat apps or other coding tools. <br>
|
|
21
|
+
This does require a paid ChatGPT account.
|
|
22
|
+
|
|
23
|
+
## Quickstart
|
|
24
|
+
|
|
25
|
+
### Homebrew
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
brew tap RayBytes/chatmock
|
|
29
|
+
brew install chatmock
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### CLI
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pipx install chatmock
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### GUI
|
|
39
|
+
|
|
40
|
+
If you're on **macOS** or **Windows**, you can download the GUI app from the [GitHub releases](https://github.com/RayBytes/ChatMock/releases).
|
|
41
|
+
|
|
42
|
+
### Python
|
|
43
|
+
If you wish to just simply run this as a python flask server, you are also freely welcome too.
|
|
44
|
+
|
|
45
|
+
Clone or download this repository, then cd into the project directory. Then follow the instrunctions listed below.
|
|
46
|
+
|
|
47
|
+
1. Sign in with your ChatGPT account and follow the prompts
|
|
48
|
+
```bash
|
|
49
|
+
python chatmock.py login
|
|
50
|
+
```
|
|
51
|
+
You can make sure this worked by running `python chatmock.py info`
|
|
52
|
+
|
|
53
|
+
2. After the login completes successfully, you can just simply start the local server
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
python chatmock.py serve
|
|
57
|
+
```
|
|
58
|
+
Then, you can simply use the address and port as the baseURL as you require (http://127.0.0.1:8000 by default)
|
|
59
|
+
|
|
60
|
+
**Reminder:** When setting a baseURL in other applications, make you sure you include /v1/ at the end of the URL if you're using this as a OpenAI compatible endpoint (e.g http://127.0.0.1:8000/v1)
|
|
61
|
+
|
|
62
|
+
### Docker
|
|
63
|
+
|
|
64
|
+
Read [the docker instrunctions here](https://github.com/RayBytes/ChatMock/blob/main/DOCKER.md)
|
|
65
|
+
|
|
66
|
+
# Examples
|
|
67
|
+
|
|
68
|
+
### Python
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
from openai import OpenAI
|
|
72
|
+
|
|
73
|
+
client = OpenAI(
|
|
74
|
+
base_url="http://127.0.0.1:8000/v1",
|
|
75
|
+
api_key="key" # ignored
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
resp = client.chat.completions.create(
|
|
79
|
+
model="gpt-5.4",
|
|
80
|
+
messages=[{"role": "user", "content": "hello world"}]
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
print(resp.choices[0].message.content)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### curl
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
curl http://127.0.0.1:8000/v1/chat/completions \
|
|
90
|
+
-H "Authorization: Bearer key" \
|
|
91
|
+
-H "Content-Type: application/json" \
|
|
92
|
+
-d '{
|
|
93
|
+
"model": "gpt-5.4",
|
|
94
|
+
"messages": [{"role":"user","content":"hello world"}]
|
|
95
|
+
}'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
# What's supported
|
|
99
|
+
|
|
100
|
+
- Tool/Function calling
|
|
101
|
+
- Vision/Image understanding
|
|
102
|
+
- Thinking summaries (through thinking tags)
|
|
103
|
+
- Thinking effort
|
|
104
|
+
|
|
105
|
+
## Notes & Limits
|
|
106
|
+
|
|
107
|
+
- Requires an active, paid ChatGPT account.
|
|
108
|
+
- Some context length might be taken up by internal instructions (but they dont seem to degrade the model)
|
|
109
|
+
- Use responsibly and at your own risk. This project is not affiliated with OpenAI, and is a educational exercise.
|
|
110
|
+
|
|
111
|
+
# Supported models
|
|
112
|
+
- `gpt-5.4`
|
|
113
|
+
- `gpt-5.2`
|
|
114
|
+
- `gpt-5.1`
|
|
115
|
+
- `gpt-5`
|
|
116
|
+
- `gpt-5.3-codex`
|
|
117
|
+
- `gpt-5-codex`
|
|
118
|
+
- `gpt-5.2-codex`
|
|
119
|
+
- `gpt-5.1-codex`
|
|
120
|
+
- `gpt-5.1-codex-max`
|
|
121
|
+
- `gpt-5.1-codex-mini`
|
|
122
|
+
- `codex-mini`
|
|
123
|
+
|
|
124
|
+
# Customisation / Configuration
|
|
125
|
+
|
|
126
|
+
### Thinking effort
|
|
127
|
+
|
|
128
|
+
- `--reasoning-effort` (choice of none,minimal,low,medium,high,xhigh)<br>
|
|
129
|
+
GPT-5 has a configurable amount of "effort" it can put into thinking, which may cause it to take more time for a response to return, but may overall give a smarter answer. Applying this parameter after `serve` forces the server to use this reasoning effort by default, unless overrided by the API request with a different effort set. The default reasoning effort without setting this parameter is `medium`.<br>
|
|
130
|
+
The `gpt-5.1` family (including codex) supports `low`, `medium`, and `high` while `gpt-5.1-codex-max` adds `xhigh`. The `gpt-5.2` and `gpt-5.3` families (including codex) support `low`, `medium`, `high`, and `xhigh`. GPT-5.4 supports `none`, `low`, `medium`, `high`, and `xhigh`.
|
|
131
|
+
|
|
132
|
+
### Thinking summaries
|
|
133
|
+
|
|
134
|
+
- `--reasoning-summary` (choice of auto,concise,detailed,none)<br>
|
|
135
|
+
Models like GPT-5 do not return raw thinking content, but instead return thinking summaries. These can also be customised by you.
|
|
136
|
+
|
|
137
|
+
### OpenAI Tools
|
|
138
|
+
|
|
139
|
+
- `--enable-web-search`<br>
|
|
140
|
+
You can also access OpenAI tools through this project. Currently, only web search is available.
|
|
141
|
+
You can enable it by starting the server with this parameter, which will allow OpenAI to determine when a request requires a web search, or you can use the following parameters during a request to the API to enable web search:
|
|
142
|
+
<br><br>
|
|
143
|
+
`responses_tools`: supports `[{"type":"web_search"}]` / `{ "type": "web_search_preview" }`<br>
|
|
144
|
+
`responses_tool_choice`: `"auto"` or `"none"`
|
|
145
|
+
|
|
146
|
+
#### Example usage
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"model": "gpt-5.4",
|
|
150
|
+
"messages": [{"role":"user","content":"Find current METAR rules"}],
|
|
151
|
+
"stream": true,
|
|
152
|
+
"responses_tools": [{"type": "web_search"}],
|
|
153
|
+
"responses_tool_choice": "auto"
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Expose reasoning models
|
|
158
|
+
|
|
159
|
+
- `--expose-reasoning-models`<br>
|
|
160
|
+
If your preferred app doesn’t support selecting reasoning effort, or you just want a simpler approach, this parameter exposes each reasoning level as a separate, queryable model. Each reasoning level also appears individually under /v1/models, so model pickers in your favorite chat apps will list all reasoning options as distinct models you can switch between.
|
|
161
|
+
|
|
162
|
+
## Notes
|
|
163
|
+
If you wish to have the fastest responses, I'd recommend setting `--reasoning-effort` to low, and `--reasoning-summary` to none. <br>
|
|
164
|
+
All parameters and choices can be seen by sending `python chatmock.py serve --h`<br>
|
|
165
|
+
The context size of this route is also larger than what you get access to in the regular ChatGPT app.<br>
|
|
166
|
+
|
|
167
|
+
When the model returns a thinking summary, the model will send back thinking tags to make it compatible with chat apps. **If you don't like this behavior, you can instead set `--reasoning-compat` to legacy, and reasoning will be set in the reasoning tag instead of being returned in the actual response text.**
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## Star History
|
|
171
|
+
|
|
172
|
+
[](https://www.star-history.com/#RayBytes/ChatMock&Timeline)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from flask import Flask, jsonify
|
|
4
|
+
|
|
5
|
+
from .config import BASE_INSTRUCTIONS, GPT5_CODEX_INSTRUCTIONS
|
|
6
|
+
from .http import build_cors_headers
|
|
7
|
+
from .routes_openai import openai_bp
|
|
8
|
+
from .routes_ollama import ollama_bp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def create_app(
|
|
12
|
+
verbose: bool = False,
|
|
13
|
+
verbose_obfuscation: bool = False,
|
|
14
|
+
reasoning_effort: str = "medium",
|
|
15
|
+
reasoning_summary: str = "auto",
|
|
16
|
+
reasoning_compat: str = "think-tags",
|
|
17
|
+
debug_model: str | None = None,
|
|
18
|
+
expose_reasoning_models: bool = False,
|
|
19
|
+
default_web_search: bool = False,
|
|
20
|
+
) -> Flask:
|
|
21
|
+
app = Flask(__name__)
|
|
22
|
+
|
|
23
|
+
app.config.update(
|
|
24
|
+
VERBOSE=bool(verbose),
|
|
25
|
+
VERBOSE_OBFUSCATION=bool(verbose_obfuscation),
|
|
26
|
+
REASONING_EFFORT=reasoning_effort,
|
|
27
|
+
REASONING_SUMMARY=reasoning_summary,
|
|
28
|
+
REASONING_COMPAT=reasoning_compat,
|
|
29
|
+
DEBUG_MODEL=debug_model,
|
|
30
|
+
BASE_INSTRUCTIONS=BASE_INSTRUCTIONS,
|
|
31
|
+
GPT5_CODEX_INSTRUCTIONS=GPT5_CODEX_INSTRUCTIONS,
|
|
32
|
+
EXPOSE_REASONING_MODELS=bool(expose_reasoning_models),
|
|
33
|
+
DEFAULT_WEB_SEARCH=bool(default_web_search),
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
@app.get("/")
|
|
37
|
+
@app.get("/health")
|
|
38
|
+
def health():
|
|
39
|
+
return jsonify({"status": "ok"})
|
|
40
|
+
|
|
41
|
+
@app.after_request
|
|
42
|
+
def _cors(resp):
|
|
43
|
+
for k, v in build_cors_headers().items():
|
|
44
|
+
resp.headers.setdefault(k, v)
|
|
45
|
+
return resp
|
|
46
|
+
|
|
47
|
+
app.register_blueprint(openai_bp)
|
|
48
|
+
app.register_blueprint(ollama_bp)
|
|
49
|
+
|
|
50
|
+
return app
|