-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed as not planned
Closed as not planned
Copy link
Labels
Description
Please read this first
- Have you read the docs?Agents SDK docs yes
- Have you searched for related issues? Others may have had similar requests yes
Question
Describe your question. Provide details if available.
below is the common api call

import json, uuid, math, time, base64, hashlib, datetime, requests
url = "http://xxx.xx.xx.xx:xxx/chat/completions/inference-xxxx-xxxx"
appid = "xx-xx-xx"
appKey = "96e8dfghghjjhgjxcvwytium11gfgf87dsd3adffdsfsd"
capabilityname = "000000000000000000000000"
_uuid = "".join(str(uuid.uuid4()).split('-'))
xServerParam = {
"appid": appid,
"csid": appid + capabilityname + _uuid
}
xCurTime = str(math.floor(time.time()))
xServerParam = str(base64.b64encode(json.dumps(xServerParam).encode('utf-8')), encoding="utf8")
xCheckSum = hashlib.md5(bytes(appKey + xCurTime + xServerParam, encoding="utf8")).hexdigest()
print(xServerParam)
headers = {
"X-Server-Param": xServerParam,
"X-CurTime": xCurTime,
"X-CheckSum": xCheckSum,
'content-type': 'application/json;charset=UTF-8',
'Accept': 'text/event-stream'
}
query = "hello,tell me about yourself"
data = {
"model": "Qwen2.5-7B-Instruct",
"repetition_penalty": 1.05,
"temperature": 0.8,
"top_p": 0.9,
"top_k": 20,
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": query}
],
"stream": True
}
first = True
result = ""
print("[{}] send request".format(datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S:%f')))
start_time = time.time()
response = requests.post(url, headers=headers, data=json.dumps(data), stream=True)
print(response)
for line in response.iter_lines():
if line:
text = line.decode("utf-8")
print(text, end="\n", flush=True)
end_time = time.time()
print("time cost: {:.4f}s".format(end_time - `start_time))`
response is like this , it's an openai format .

I try some way to integerated, but not worked!
I want to know is agents-python support these kind of work?
If support, how to achive?