Fix long tool call id handling and add Chinese quick usage.
Build Status / build (push) Successful in 1m52s
Build Status / build (push) Successful in 1m52s
Normalize tool call IDs to Azure's 64-char limit and document a Chinese quick setup flow for Cursor + Azure GPT-5.4 deployment. Made-with: Cursor
This commit is contained in:
@@ -280,4 +280,32 @@ docker tag app-production your-tag
|
||||
docker push your-tag
|
||||
```
|
||||
|
||||
</details>
|
||||
</details>
|
||||
|
||||
## Chinese Quick Usage (Cursor + Azure GPT-5.4)
|
||||
|
||||
1. Deploy and run service:
|
||||
|
||||
```bash
|
||||
docker compose up -d flask-prod
|
||||
```
|
||||
|
||||
2. Set `.env` key values:
|
||||
|
||||
```env
|
||||
SERVICE_API_KEY=change-me
|
||||
AZURE_BASE_URL=https://<your-resource>.cognitiveservices.azure.com
|
||||
AZURE_API_KEY=<your-azure-api-key>
|
||||
AZURE_DEPLOYMENT=gpt-5.4
|
||||
```
|
||||
|
||||
3. In Cursor settings:
|
||||
- Override OpenAI Base URL: your public URL, e.g. `https://<your-tunnel>.trycloudflare.com`
|
||||
- OpenAI API Key: same as `SERVICE_API_KEY`
|
||||
- Add custom models: `gpt-high`, `gpt-medium`, `gpt-low`, `gpt-minimal`
|
||||
|
||||
4. Optional quick tunnel:
|
||||
|
||||
```bash
|
||||
cloudflared tunnel --url http://localhost:8080
|
||||
```
|
||||
@@ -58,6 +58,12 @@ class RequestAdapter:
|
||||
headers["api-key"] = api_key
|
||||
return headers
|
||||
|
||||
def _normalize_call_id(self, call_id: Any) -> str:
|
||||
"""Return an Azure-compatible call_id (max length 64)."""
|
||||
if call_id is None:
|
||||
return ""
|
||||
return str(call_id)[:64]
|
||||
|
||||
def _messages_to_responses_input_and_instructions(
|
||||
self, messages: List[Dict[str, Any]]
|
||||
) -> Dict[str, Any]:
|
||||
@@ -72,7 +78,7 @@ class RequestAdapter:
|
||||
continue
|
||||
# For user/assistant/tools as inputs
|
||||
if role == "tool":
|
||||
call_id = m.get("tool_call_id")
|
||||
call_id = self._normalize_call_id(m.get("tool_call_id"))
|
||||
item = {
|
||||
"type": "function_call_output",
|
||||
"output": self._content_to_text(content),
|
||||
@@ -96,7 +102,7 @@ class RequestAdapter:
|
||||
if tool_calls := m.get("tool_calls"):
|
||||
for tool_call in tool_calls:
|
||||
function = tool_call.get("function", {})
|
||||
call_id = tool_call.get("id")
|
||||
call_id = self._normalize_call_id(tool_call.get("id"))
|
||||
item = {
|
||||
"type": "function_call",
|
||||
"name": function.get("name"),
|
||||
|
||||
Reference in New Issue
Block a user