@@ -87,9 +87,12 @@ var yChat: YChat {
8787
8888do {
8989 let result = try await yChat.completion ()
90+ .setModel (input : " text-davinci-003" )
9091 .setInput (input : " Say this is a test." )
9192 .setMaxTokens (tokens : 1024 )
92- .set // you can set more parameters
93+ .setTemperature (temperature : 1.0 )
94+ .setTopP (topP : 1.0 )
95+ .saveHistory (isSaveHistory : false )
9396 .execute ()
9497} catch {
9598 // catch any error that may occurs on api call.
@@ -105,9 +108,12 @@ val yChat by lazy {
105108
106109try {
107110 val result = yChat.completion()
111+ .setModel(" text-davinci-003" )
108112 .setInput(" Say this is a test." )
109113 .setMaxTokens(1024 )
110- .set // you can set more parameters
114+ .setTemperature(1.0 )
115+ .setTopP(1.0 )
116+ .saveHistory(false )
111117 .execute()
112118} catch (e: exception) {
113119 // catch any error that may occurs on api call.
@@ -127,12 +133,15 @@ var yChat: YChat {
127133
128134do {
129135 let result = try await yChat.chatCompletions ()
136+ .setModel (model : " gpt-3.5-turbo" )
130137 .setMaxTokens (tokens : 1024 )
138+ .setMaxResults (results : 1 )
139+ .setTemperature (temperature : 1.0 )
140+ .setTopP (topP : 1.0 )
131141 .addMessage (
132142 role : " assistant" ,
133143 content : " You are a helpful assistant that only answers questions related to fitness"
134144 )
135- .set // you can set more parameters
136145 .execute (content : " What is the best exercise for building muscle?" )
137146} catch {
138147 // catch any error that may occurs on api call.
@@ -148,12 +157,15 @@ val yChat by lazy {
148157
149158try {
150159 val result = yChat.chatCompletions()
160+ .setModel(" gpt-3.5-turbo" )
151161 .setMaxTokens(1024 )
162+ .setMaxResults(1 )
163+ .setTemperature(1.0 )
164+ .setTopP(1.0 )
152165 .addMessage(
153166 role = " assistant" ,
154167 content = " You are a helpful assistant that only answers questions related to fitness"
155168 )
156- .set // you can set more parameters
157169 .execute(" What is the best exercise for building muscle?" )
158170} catch (e: exception) {
159171 // catch any error that may occurs on api call.
@@ -173,9 +185,9 @@ var yChat: YChat {
173185
174186do {
175187 let result = try await yChat.imageGenerations ()
176- .setResults (results : 2 )
188+ .setResults (results : 1 )
177189 .setSize (size : " 1024x1024" )
178- .set // you can set more parameters
190+ .setResponseFormat ( responseFormat : " url " )
179191 .execute (prompt : " ocean" )
180192} catch {
181193 // catch any error that may occurs on api call.
@@ -191,9 +203,9 @@ val yChat by lazy {
191203
192204try {
193205 val result = yChat.imageGenerations()
194- .setResults(2 )
206+ .setResults(1 )
195207 .setSize(" 1024x1024" )
196- .set // you can set more parameters
208+ .setResponseFormat( " url " )
197209 .execute(" ocean" )
198210} catch (e: exception) {
199211 // catch any error that may occurs on api call.
215227 let result = try await yChat.edits ()
216228 .setInput (input : " What day of the wek is it?" )
217229 .setResults (result : 1 )
218- .set // you can set more parameters
230+ .setModel (model : " text-davinci-edit-001" )
231+ .setTemperature (temperature : 1.0 )
232+ .setTopP (topP : 1.0 )
219233 .execute (instruction : " Fix the spelling mistakes" )
220234} catch {
221235 // catch any error that may occurs on api call.
@@ -233,7 +247,9 @@ try {
233247 val result = yChat.edits()
234248 .setInput(" What day of the wek is it?" )
235249 .setResults(1 )
236- .set // you can set more parameters
250+ .setModel(" text-davinci-edit-001" )
251+ .setTemperature(1.0 )
252+ .setTopP(1.0 )
237253 .execute(" Fix the spelling mistakes" )
238254} catch (e: exception) {
239255 // catch any error that may occurs on api call.
@@ -260,9 +276,11 @@ let audioData = try! Data(contentsOf: audioFileUrl)
260276
261277do {
262278 let result = try await yChat.audioTranscriptions ()
263- .setTemperature (temperature : 0.4 )
279+ .setModel (model : " whisper-1" )
280+ .setPrompt (prompt : " " )
264281 .setResponseFormat (format : " json" )
265- .set // you can set more parameters
282+ .setTemperature (temperature : 0.4 )
283+ .setLanguage (language : " en" )
266284 .execute (filename : " audio.m4a" , audioFile : audioData)
267285} catch {
268286 // catch any error that may occurs on api call.
@@ -281,9 +299,11 @@ val byteArray = inputStream.readBytes()
281299
282300try {
283301 val result = yChat.audioTranscriptions()
284- .setTemperature(0.4 )
302+ .setModel(" whisper-1" )
303+ .setPrompt(" " )
285304 .setResponseFormat(" json" )
286- .set // you can set more parameters
305+ .setTemperature(0.4 )
306+ .setLanguage(" en" )
287307 .execute(" audio.m4a" , byteArray)
288308} catch (e: exception) {
289309 // catch any error that may occurs on api call.
0 commit comments