Skip to content

Commit 7040607

Browse files
committed
revert test_server.py
1 parent b30ef69 commit 7040607

File tree

3 files changed

+90
-80
lines changed

3 files changed

+90
-80
lines changed

start_server.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

test/test_openai_server.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import time
2+
import requests
3+
import json
4+
import threading
5+
6+
7+
class RequestThread(threading.Thread):
8+
def __init__(self, url, headers, data):
9+
threading.Thread.__init__(self)
10+
self.url = url
11+
self.headers = headers
12+
self.data = data
13+
14+
def run(self):
15+
response = requests.post(self.url, headers=self.headers, data=json.dumps(self.data))
16+
if response.status_code == 200:
17+
print(response.json())
18+
else:
19+
print("Error:", response.status_code, response.text)
20+
21+
22+
openai_url = "http://localhost:8888/v1/chat/completions"
23+
headers = {"Content-Type": "application/json"}
24+
25+
# Test OpenAI Tool Call API
26+
messages = [
27+
{
28+
"role": "user",
29+
"content": "What's the weather like in Boston today? "
30+
"Output a reasoning before act, then use the tools to help you.",
31+
}
32+
]
33+
tools = [
34+
{
35+
"type": "function",
36+
"function": {
37+
"name": "get_current_weather",
38+
"description": "Get the current weather in a given location",
39+
"parameters": {
40+
"type": "object",
41+
"properties": {
42+
"city": {
43+
"type": "string",
44+
"description": "The city to find the weather for, e.g. 'San Francisco'",
45+
},
46+
"state": {
47+
"type": "string",
48+
"description": "the two-letter abbreviation for the state that the city is"
49+
" in, e.g. 'CA' which would mean 'California'",
50+
},
51+
"unit": {
52+
"type": "string",
53+
"description": "The unit to fetch the temperature in",
54+
"enum": ["celsius", "fahrenheit"],
55+
},
56+
},
57+
"required": ["city", "state", "unit"],
58+
},
59+
},
60+
}
61+
]
62+
63+
for i in range(1):
64+
data = {
65+
"model": "qwen25",
66+
"messages": messages,
67+
"tools": tools,
68+
"do_sample": False,
69+
"max_tokens": 1024,
70+
}
71+
thread = RequestThread(openai_url, headers, data)
72+
thread.start()

test/test_server.py

Lines changed: 18 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -19,81 +19,30 @@ def run(self):
1919
print("Error:", response.status_code, response.text)
2020

2121

22-
openai_url = "http://localhost:8888/v1/chat/completions"
2322
url = "http://localhost:8000/generate"
2423
headers = {"Content-Type": "application/json"}
2524

26-
# Test OpenAI Tool Call API
27-
messages = [
28-
{
29-
"role": "user",
30-
"content": "What's the weather like in Boston today? "
31-
"Output a reasoning before act, then use the tools to help you.",
32-
}
33-
]
34-
tools = [
35-
{
36-
"type": "function",
37-
"function": {
38-
"name": "get_current_weather",
39-
"description": "Get the current weather in a given location",
40-
"parameters": {
41-
"type": "object",
42-
"properties": {
43-
"city": {
44-
"type": "string",
45-
"description": "The city to find the weather for, e.g. 'San Francisco'",
46-
},
47-
"state": {
48-
"type": "string",
49-
"description": "the two-letter abbreviation for the state that the city is"
50-
" in, e.g. 'CA' which would mean 'California'",
51-
},
52-
"unit": {
53-
"type": "string",
54-
"description": "The unit to fetch the temperature in",
55-
"enum": ["celsius", "fahrenheit"],
56-
},
57-
},
58-
"required": ["city", "state", "unit"],
59-
},
60-
},
61-
}
62-
]
6325
for i in range(1):
6426
data = {
65-
"model": "qwen25",
66-
"messages": messages,
67-
"tools": tools,
68-
"do_sample": False,
69-
"max_tokens": 1024,
27+
"inputs": "San Francisco is a",
28+
# 'temperature': 0.1,
29+
"parameters": {
30+
"do_sample": False,
31+
},
7032
}
71-
thread = RequestThread(openai_url, headers, data)
33+
thread = RequestThread(url, headers, data)
7234
thread.start()
7335

36+
time.sleep(2)
7437

75-
# Test LightLLM API
76-
# for i in range(1):
77-
# data = {
78-
# 'inputs': 'San Francisco is a',
79-
# # 'temperature': 0.1,
80-
# 'parameters' : {
81-
# 'do_sample': False,
82-
# }
83-
# }
84-
# thread = RequestThread(url, headers, data)
85-
# thread.start()
86-
87-
# time.sleep(2)
88-
89-
# for i in range(20):
90-
# data = {
91-
# 'inputs': 'San Francisco is a',
92-
# 'parameters': {
93-
# 'do_sample': False,
94-
# 'ignore_eos': True,
95-
# 'max_new_tokens': 200,
96-
# }
97-
# }
98-
# thread = RequestThread(url, headers, data)
99-
# thread.start()
38+
for i in range(20):
39+
data = {
40+
"inputs": "San Francisco is a",
41+
"parameters": {
42+
"do_sample": False,
43+
"ignore_eos": True,
44+
"max_new_tokens": 200,
45+
},
46+
}
47+
thread = RequestThread(url, headers, data)
48+
thread.start()

0 commit comments

Comments
 (0)