Skip to content

Commit 0b2031f

Browse files
committed
update
1 parent cbc9590 commit 0b2031f

3 files changed

Lines changed: 94 additions & 1 deletion

File tree

chat-plugin/main-bk.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chat-plugin/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/fake_model_server.py

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import argparse
2+
from flask import Flask, jsonify
3+
4+
# Initialize a Flask app
5+
app = Flask(__name__)
6+
7+
# Sample mock data for /v1/models
8+
MOCK_MODELS = {
9+
"object": "list",
10+
"data": [
11+
{
12+
"id": "text-davinci-003",
13+
"object": "model",
14+
"created": 1649368800,
15+
"owned_by": "openai",
16+
"permission": [
17+
{
18+
"id": "modelperm-abc123",
19+
"object": "model_permission",
20+
"created": 1649368800,
21+
"allow_create_engine": True,
22+
"allow_sampling": True,
23+
"allow_logprobs": True,
24+
"allow_search_indices": False,
25+
"organization": "*",
26+
"is_blocking": False,
27+
}
28+
],
29+
},
30+
{
31+
"id": "text-curie-001",
32+
"object": "model",
33+
"created": 1649368801,
34+
"owned_by": "openai",
35+
"permission": [
36+
{
37+
"id": "modelperm-def456",
38+
"object": "model_permission",
39+
"created": 1649368801,
40+
"allow_create_engine": True,
41+
"allow_sampling": True,
42+
"allow_logprobs": True,
43+
"allow_search_indices": False,
44+
"organization": "*",
45+
"is_blocking": False,
46+
}
47+
],
48+
},
49+
{
50+
"id": "text-babbage-001",
51+
"object": "model",
52+
"created": 1649368802,
53+
"owned_by": "openai",
54+
"permission": [
55+
{
56+
"id": "modelperm-ghi789",
57+
"object": "model_permission",
58+
"created": 1649368802,
59+
"allow_create_engine": True,
60+
"allow_sampling": True,
61+
"allow_logprobs": True,
62+
"allow_search_indices": False,
63+
"organization": "*",
64+
"is_blocking": False,
65+
}
66+
],
67+
},
68+
],
69+
}
70+
71+
# Define the endpoint for GET /v1/models
72+
@app.route('/v1/models', methods=['GET'])
73+
def get_models():
74+
# Return the mock data as a JSON response
75+
return jsonify(MOCK_MODELS)
76+
77+
# Main script to run the Flask app
78+
if __name__ == '__main__':
79+
# Setup command-line argument parsing
80+
parser = argparse.ArgumentParser(description="Run a fake OpenAI API server.")
81+
parser.add_argument(
82+
'--port',
83+
type=int,
84+
default=5000,
85+
help="Port to run the server on. Default is 5000."
86+
)
87+
args = parser.parse_args()
88+
89+
# Run the Flask app on the specified port
90+
app.run(debug=True, port=args.port)

0 commit comments

Comments
 (0)