forked from Azure-Samples/openai-python-enterprise-logging
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgpt-35-turbo-instruct-fullpolicy.xml
58 lines (58 loc) · 3.1 KB
/
gpt-35-turbo-instruct-fullpolicy.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<policies>
<inbound>
<base />
<set-variable name="deploymentId" value="/deployments/gpt-35-turbo-instruct" />
<set-variable name="urlId" value="@(new Random(context.RequestId.GetHashCode()).Next(1, 3))" />
<choose>
<when condition="@(context.Variables.GetValueOrDefault<int>("urlId") == 1)">
<set-variable name="backendUrl" value="{{aoai-australiaeast-endpoint}}" />
<set-header name="api-key" exists-action="override">
<value>{{aoai-australiaeast-key}}</value>
</set-header>
</when>
<when condition="@(context.Variables.GetValueOrDefault<int>("urlId") == 2)">
<set-variable name="backendUrl" value="{{aoai-swedencentral-endpoint}}" />
<set-header name="api-key" exists-action="override">
<value>{{aoai-swedencentral-key}}</value>
</set-header>
</when>
</choose>
<cache-lookup vary-by-developer="false" vary-by-developer-groups="false" downstream-caching-type="none">
<vary-by-header>Accept</vary-by-header>
<vary-by-header>Accept-Charset</vary-by-header>
<vary-by-header>Authorization</vary-by-header>
</cache-lookup>
<set-backend-service base-url="@((string)context.Variables["backendUrl"] + (string)context.Variables["deploymentId"])" />
</inbound>
<backend>
<retry condition="@(context.Response.StatusCode == 429)" count="18" interval="4" delta="2" first-fast-retry="true">
<set-variable name="urlId" value="@(context.Variables.GetValueOrDefault<int>("urlId") % 2 + 1)" />
<choose>
<when condition="@(context.Response != null && (context.Response.StatusCode == 429 ) && context.Variables.GetValueOrDefault<int>("urlId") == 1)">
<set-variable name="backendUrl" value="{{aoai-australiaeast-endpoint}}" />
<set-header name="api-key" exists-action="override">
<value>{{aoai-australiaeast-key}}</value>
</set-header>
</when>
<when condition="@(context.Response != null && (context.Response.StatusCode == 429 ) && context.Variables.GetValueOrDefault<int>("urlId") == 2)">
<set-variable name="backendUrl" value="{{aoai-swedencentral-endpoint}}" />
<set-header name="api-key" exists-action="override">
<value>{{aoai-swedencentral-key}}</value>
</set-header>
</when>
</choose>
<set-backend-service base-url="@((string)context.Variables["backendUrl"] + (string)context.Variables["deploymentId"])" />
<forward-request buffer-request-body="true" />
</retry>
</backend>
<outbound>
<set-header name="Backend-Service-URL" exists-action="override">
<value>@((string)context.Variables["backendUrl"])</value>
</set-header>
<cache-store duration="20" />
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>