Skip to content

Commit 450dbaf

Browse files
Devon-Whiteniravcodeshey-august
authored
Migrate SWML schema to docs repo (#540)
Co-authored-by: Nirav Nikhil <[email protected]> Co-authored-by: August <[email protected]>
1 parent 1a267e9 commit 450dbaf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+12678
-3
lines changed

specs/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"version": "0.0.0",
44
"private": true,
55
"scripts": {
6-
"build": "yarn build:calling-api && yarn build:chat-api && yarn build:datasphere-api && yarn build:fabric-api && yarn build:logs-api && yarn build:fax-api && yarn build:message-api && yarn build:voice-api && yarn build:pubsub-api",
6+
"build": "yarn build:api",
7+
"build:all": "yarn build:api && yarn build:schema",
8+
"build:api": "yarn build:calling-api && yarn build:chat-api && yarn build:datasphere-api && yarn build:fabric-api && yarn build:logs-api && yarn build:fax-api && yarn build:message-api && yarn build:voice-api && yarn build:pubsub-api",
9+
"build:schema": "yarn build:swml",
10+
"build:swml": "cd ./swml && tsp compile . && cd ../",
711
"build:calling-api": "cd ./signalwire-rest/calling-api && tsp compile . && cd ../../",
812
"build:chat-api": "cd ./signalwire-rest/chat-api && tsp compile . && cd ../../",
913
"build:datasphere-api": "cd ./signalwire-rest/datasphere-api && tsp compile . && cd ../../",
@@ -21,6 +25,7 @@
2125
"dependencies": {
2226
"@typespec/compiler": "1.3.0",
2327
"@typespec/http": "1.3.0",
28+
"@typespec/json-schema": "1.3.0",
2429
"@typespec/openapi": "1.3.0",
2530
"@typespec/openapi3": "1.3.0",
2631
"@typespec/rest": "0.73.0"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SignalWire REST APIs configuration - generates OpenAPI
2+
extends: ../tspconfig.yaml
3+
emit:
4+
- "@typespec/openapi3"
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
import "@typespec/json-schema";
2+
3+
using TypeSpec.JsonSchema;
4+
5+
@doc("Supported language codes")
6+
@oneOf
7+
union FunctionFillers {
8+
{
9+
@doc("Default language set by the user")
10+
default: string[],
11+
},
12+
{
13+
@doc("Bulgarian")
14+
bg: string[],
15+
},
16+
{
17+
@doc("Catalan")
18+
ca: string[],
19+
},
20+
{
21+
@doc("Chinese (Simplified)")
22+
zh: string[],
23+
},
24+
{
25+
@doc("Chinese (Simplified, China)")
26+
`zh-CN`: string[],
27+
},
28+
{
29+
@doc("Chinese (Simplified Han)")
30+
`zh-Hans`: string[],
31+
},
32+
{
33+
@doc("Chinese (Traditional, Taiwan)")
34+
`zh-TW`: string[],
35+
},
36+
{
37+
@doc("Chinese (Traditional Han)")
38+
`zh-Hant`: string[],
39+
},
40+
{
41+
@doc("Chinese (Traditional, Hong Kong)")
42+
`zh-HK`: string[],
43+
},
44+
{
45+
@doc("Czech")
46+
cs: string[],
47+
},
48+
{
49+
@doc("Danish")
50+
da: string[],
51+
},
52+
{
53+
@doc("Danish (Denmark)")
54+
`da-DK`: string[],
55+
},
56+
{
57+
@doc("Dutch")
58+
nl: string[],
59+
},
60+
{
61+
@doc("English")
62+
en: string[],
63+
},
64+
{
65+
@doc("English (United States)")
66+
`en-US`: string[],
67+
},
68+
{
69+
@doc("English (United Kingdom)")
70+
`en-GB`: string[],
71+
},
72+
{
73+
@doc("English (New Zealand)")
74+
`en-NZ`: string[],
75+
},
76+
{
77+
@doc("English (India)")
78+
`en-IN`: string[],
79+
},
80+
{
81+
@doc("English (Australia)")
82+
`en-AU`: string[],
83+
},
84+
{
85+
@doc("Estonian")
86+
et: string[],
87+
},
88+
{
89+
@doc("Finnish")
90+
fi: string[],
91+
},
92+
{
93+
@doc("Flemish (Belgian Dutch)")
94+
`nl-BE`: string[],
95+
},
96+
{
97+
@doc("French")
98+
fr: string[],
99+
},
100+
{
101+
@doc("French (Canada)")
102+
`fr-CA`: string[],
103+
},
104+
{
105+
@doc("German")
106+
de: string[],
107+
},
108+
{
109+
@doc("German (Switzerland)")
110+
`de-CH`: string[],
111+
},
112+
{
113+
@doc("Greek")
114+
el: string[],
115+
},
116+
{
117+
@doc("Hindi")
118+
hi: string[],
119+
},
120+
{
121+
@doc("Hungarian")
122+
hu: string[],
123+
},
124+
{
125+
@doc("Indonesian")
126+
id: string[],
127+
},
128+
{
129+
@doc("Italian")
130+
it: string[],
131+
},
132+
{
133+
@doc("Japanese")
134+
ja: string[],
135+
},
136+
{
137+
@doc("Korean")
138+
ko: string[],
139+
},
140+
{
141+
@doc("Korean (South Korea)")
142+
`ko-KR`: string[],
143+
},
144+
{
145+
@doc("Latvian")
146+
lv: string[],
147+
},
148+
{
149+
@doc("Lithuanian")
150+
lt: string[],
151+
},
152+
{
153+
@doc("Malay")
154+
ms: string[],
155+
},
156+
{
157+
@doc("Multilingual (Spanish + English)")
158+
multi: string[],
159+
},
160+
{
161+
@doc("Norwegian")
162+
no: string[],
163+
},
164+
{
165+
@doc("Polish")
166+
pl: string[],
167+
},
168+
{
169+
@doc("Portuguese")
170+
pt: string[],
171+
},
172+
{
173+
@doc("Portuguese (Brazil)")
174+
`pt-BR`: string[],
175+
},
176+
{
177+
@doc("Portuguese (Portugal)")
178+
`pt-PT`: string[],
179+
},
180+
{
181+
@doc("Romanian")
182+
ro: string[],
183+
},
184+
{
185+
@doc("Russian")
186+
ru: string[],
187+
},
188+
{
189+
@doc("Slovak")
190+
sk: string[],
191+
},
192+
{
193+
@doc("Spanish")
194+
es: string[],
195+
},
196+
{
197+
@doc("Spanish (Latin America)")
198+
`es-419`: string[],
199+
},
200+
{
201+
@doc("Swedish")
202+
sv: string[],
203+
},
204+
{
205+
@doc("Swedish (Sweden)")
206+
`sv-SE`: string[],
207+
},
208+
{
209+
@doc("Thai")
210+
th: string[],
211+
},
212+
{
213+
@doc("Thai (Thailand)")
214+
`th-TH`: string[],
215+
},
216+
{
217+
@doc("Turkish")
218+
tr: string[],
219+
},
220+
{
221+
@doc("Ukrainian")
222+
uk: string[],
223+
},
224+
{
225+
@doc("Vietnamese")
226+
vi: string[],
227+
},
228+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import "@typespec/json-schema";
2+
3+
using TypeSpec.JsonSchema;
4+
5+
@doc("Base model for common section properties")
6+
model PomSectionBase {
7+
@doc("Title for the section")
8+
@minLength(1)
9+
title?: string;
10+
11+
@doc("Optional array of nested subsections")
12+
@minItems(1)
13+
subsections?: POM[];
14+
15+
@doc("Whether to number the section")
16+
numbered?: boolean | SWMLVar;
17+
18+
@doc("Whether to number the bullets")
19+
numberedBullets?: boolean | SWMLVar;
20+
}
21+
22+
@doc("Content model with body text and optional bullets")
23+
model PomSectionBodyContent is PomSectionBase {
24+
@doc("Body text for the section")
25+
body: string;
26+
27+
@doc("Optional array of bullet points")
28+
@minItems(1)
29+
bullets?: string[];
30+
}
31+
32+
@doc("Content model with bullets and optional body")
33+
model PomSectionBulletsContent is PomSectionBase {
34+
@doc("Body text for the section (optional)")
35+
body?: string;
36+
37+
@doc("Array of bullet points")
38+
@minItems(1)
39+
bullets: string[];
40+
}
41+
42+
@doc("Regular section that requires either body or bullets.")
43+
union POM {
44+
PomSectionBodyContent,
45+
PomSectionBulletsContent,
46+
}

specs/swml/Methods/ai/ai_hints.tsp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import "@typespec/json-schema";
2+
import "../../Shared/Types/main.tsp";
3+
4+
using TypeSpec.JsonSchema;
5+
6+
model Hint {
7+
@doc("The hint to match. This will match the string exactly as provided")
8+
hint: string;
9+
10+
@doc("A regular expression to match the hint against. This will ensure that the hint has a valid matching pattern before being replaced.")
11+
pattern: string;
12+
13+
@doc("The text to replace the hint with. This will replace the portion of the hint that matches the pattern.")
14+
replace: string;
15+
16+
@doc("If true, the hint will be matched in a case-insensitive manner. Defaults to false.")
17+
ignore_case?: boolean | SWMLVar;
18+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import "@typespec/json-schema";
2+
3+
using TypeSpec.JsonSchema;
4+
5+
@summary("LanguagesBase")
6+
model LanguagesBase {
7+
@doc("Any arbirary name for the language object.")
8+
name: string;
9+
10+
@doc("The language code for the ai to hear. For example, 'fr-FR'.")
11+
code: string;
12+
13+
@doc("Voice to use for the language. For example, 'fr-FR-Neural2-B'.")
14+
voice: string;
15+
16+
@doc("The model to use for the specified TTS engine. For example, 'arcana'.")
17+
_model?: string;
18+
19+
@doc("""
20+
Enables emotion detection for the set TTS engine. This allows the AI to express emotions when speaking.
21+
A global emotion or specific emotions for certain topics can be set within the prompt of the AI.
22+
IMPORTANT: Only works with [`Cartesia`](/voice/getting-started/voice-and-languages#cartesia) TTS engine.
23+
""")
24+
emotion?: "auto";
25+
26+
@doc("""
27+
The speed to use for the specified TTS engine. This allows the AI to speak at a different speed at different points in the conversation.
28+
The speed behavior can be defined in the prompt of the AI.
29+
IMPORTANT: Only works with [`Cartesia`](/voice/getting-started/voice-and-languages#cartesia) TTS engine.
30+
""")
31+
speed?: "auto";
32+
33+
#deprecated "The `engine` property is deprecated. Please include the engine in the voice field."
34+
@doc("The engine to use for the language. For example, 'elevenlabs'.")
35+
engine?: string;
36+
}
37+
38+
@summary("LanguagesWithSoloFillers")
39+
model LanguagesWithSoloFillers is LanguagesBase {
40+
#deprecated "The `fillers` property is deprecated. Please use `function_fillers` and `speech_fillers` instead."
41+
@doc("An array of strings to be used as fillers in the conversation. This will be used for both speech and function fillers if provided.")
42+
fillers?: string[];
43+
}
44+
45+
@summary("LanguagesWithFillers")
46+
model LanguagesWithFillers is LanguagesBase {
47+
@doc("An array of strings to be used as fillers in the conversation when calling a `swaig function`. This helps the AI break silence between responses. The filler is played asynchronously during the function call.")
48+
function_fillers?: string[];
49+
50+
@doc("An array of strings to be used as fillers in the conversation. This helps the AI break silence between responses.")
51+
speech_fillers?: string[];
52+
}
53+
54+
@summary("languages")
55+
union Languages {
56+
LanguagesWithSoloFillers,
57+
LanguagesWithFillers,
58+
}

0 commit comments

Comments
 (0)