Skip to content

Commit

Permalink
Merge branch 'master' into update/akka-http-backend-4.0.0-M16
Browse files Browse the repository at this point in the history
  • Loading branch information
kciesielski authored Jul 2, 2024
2 parents c30c2c3 + fc49292 commit ed3b4e7
Show file tree
Hide file tree
Showing 13 changed files with 144 additions and 127 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@

# Scala Steward: Reformat with scalafmt 3.8.1
0da64294cb90279afc959af8a39a19227ad64372

# Scala Steward: Reformat with scalafmt 3.8.2
c1761dd17f98157d61fc8639d12803b6eafc1346
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 3.8.1
version = 3.8.2
maxColumn = 140
rewrite.rules = [RedundantBraces, RedundantParens, SortImports]
runner.dialect = scala3
16 changes: 8 additions & 8 deletions core/src/main/scala/sttp/openai/OpenAI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1078,14 +1078,14 @@ class OpenAI(authToken: String, baseUri: Uri = OpenAIUris.OpenAIBaseUri) {
.response(asJsonSnake[VectorStoreFile])

/** Deletes vector store file by id
*
* @param vectorStoreId
* Id of vector store
* @param fileId
* Id of vector store file
* @return
* Result of delete operation
*/
*
* @param vectorStoreId
* Id of vector store
* @param fileId
* Id of vector store file
* @return
* Result of delete operation
*/
def deleteVectorStoreFile(vectorStoreId: String, fileId: String): Request[Either[OpenAIException, DeleteVectorStoreFileResponse]] =
betaOpenAIAuthRequest
.delete(openAIUris.vectorStoreFile(vectorStoreId, fileId))
Expand Down
128 changes: 64 additions & 64 deletions core/src/main/scala/sttp/openai/OpenAISyncClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -691,113 +691,113 @@ class OpenAISyncClient private (authToken: String, backend: SyncBackend, closeCl
sendOrThrow(openAI.cancelRun(threadId, runId))

/** Creates vector store
*
* @param createVectorStoreBody
* Options for new vector store
* @return
* Newly created vector store or exception
*/
*
* @param createVectorStoreBody
* Options for new vector store
* @return
* Newly created vector store or exception
*/
def createVectorStore(createVectorStoreBody: CreateVectorStoreBody): VectorStore =
sendOrThrow(openAI.createVectorStore(createVectorStoreBody))

/** Lists vector store
*
* @param queryParameters
* Search params
* @return
* List of vector stores matching criteria or exception
*/
*
* @param queryParameters
* Search params
* @return
* List of vector stores matching criteria or exception
*/
def listVectorStores(
queryParameters: QueryParameters = QueryParameters.empty
): ListVectorStoresResponse =
sendOrThrow(openAI.listVectorStores(queryParameters))

/** Retrieves vector store by id
*
* @param vectorStoreId
* Id of vector store
* @return
* Vector store object or exception
*/
*
* @param vectorStoreId
* Id of vector store
* @return
* Vector store object or exception
*/
def retrieveVectorStore(vectorStoreId: String): VectorStore =
sendOrThrow(openAI.retrieveVectorStore(vectorStoreId))

/** Modifies vector store
*
* @param vectorStoreId
* Id of vector store to modify
* @param modifyVectorStoreBody
* New values for store properties
* @return
* Modified vector store object
*/
*
* @param vectorStoreId
* Id of vector store to modify
* @param modifyVectorStoreBody
* New values for store properties
* @return
* Modified vector store object
*/
def modifyVectorStore(
vectorStoreId: String,
modifyVectorStoreBody: ModifyVectorStoreBody
): VectorStore =
sendOrThrow(openAI.modifyVectorStore(vectorStoreId, modifyVectorStoreBody))

/** Deletes vector store
*
* @param vectorStoreId
* Id of vector store to be deleted
* @return
* Result of deleted operation
*/
*
* @param vectorStoreId
* Id of vector store to be deleted
* @return
* Result of deleted operation
*/
def deleteVectorStore(vectorStoreId: String): DeleteVectorStoreResponse =
sendOrThrow(openAI.deleteVectorStore(vectorStoreId))

/** Creates vector store file
*
* @param vectorStoreId
* Id of vector store for file
* @param createVectorStoreFileBody
* Properties of file
* @return
* Newly created vector store file
*/
*
* @param vectorStoreId
* Id of vector store for file
* @param createVectorStoreFileBody
* Properties of file
* @return
* Newly created vector store file
*/
def createVectorStoreFile(
vectorStoreId: String,
createVectorStoreFileBody: CreateVectorStoreFileBody
): VectorStoreFile =
sendOrThrow(openAI.createVectorStoreFile(vectorStoreId, createVectorStoreFileBody))

/** List files belonging to particular datastore
*
* @param vectorStoreId
* Id of vector store
* @param queryParameters
* Search params
* @return
* List of vector store files
*/
*
* @param vectorStoreId
* Id of vector store
* @param queryParameters
* Search params
* @return
* List of vector store files
*/
def listVectorStoreFiles(
vectorStoreId: String,
queryParameters: ListVectorStoreFilesBody = ListVectorStoreFilesBody()
): ListVectorStoreFilesResponse =
sendOrThrow(openAI.listVectorStoreFiles(vectorStoreId, queryParameters))

/** Retrieves vector store file by id
*
* @param vectorStoreId
* Id of vector store
* @param fileId
* Id of vector store file
* @return
* Vector store file
*/
*
* @param vectorStoreId
* Id of vector store
* @param fileId
* Id of vector store file
* @return
* Vector store file
*/
def retrieveVectorStoreFile(vectorStoreId: String, fileId: String): VectorStoreFile =
sendOrThrow(openAI.retrieveVectorStoreFile(vectorStoreId, fileId))

/** Deletes vector store file by id
*
* @param vectorStoreId
* Id of vector store
* @param fileId
* Id of vector store file
* @return
* Result of delete operation
*/
*
* @param vectorStoreId
* Id of vector store
* @param fileId
* Id of vector store file
* @return
* Result of delete operation
*/
def deleteVectorStoreFile(vectorStoreId: String, fileId: String): DeleteVectorStoreFileResponse =
sendOrThrow(openAI.deleteVectorStoreFile(vectorStoreId, fileId))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ object ToolResources {
{
case Some(resources) =>
(resources.fileSearch, resources.codeInterpreter) match {
case (Some(fileSearch), Some(codeInterpreter)) =>
Obj("file_search" -> SnakePickle.writeJs(fileSearch), "code_interpreter" -> SnakePickle.writeJs(codeInterpreter))
case (Some(fileSearch), None) => Obj("file_search" -> SnakePickle.writeJs(fileSearch))
case (None, Some(codeInterpreter)) => Obj("code_interpreter" -> SnakePickle.writeJs(codeInterpreter))
case _ => Obj()
}
case (Some(fileSearch), Some(codeInterpreter)) =>
Obj("file_search" -> SnakePickle.writeJs(fileSearch), "code_interpreter" -> SnakePickle.writeJs(codeInterpreter))
case (Some(fileSearch), None) => Obj("file_search" -> SnakePickle.writeJs(fileSearch))
case (None, Some(codeInterpreter)) => Obj("code_interpreter" -> SnakePickle.writeJs(codeInterpreter))
case _ => Obj()
}
case None => Obj()
},
json => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ object VectorStoreResponseData {
}

/** @param object
* Always "list"
* @param data
* A list of vector store objects.
* @param firstId
* Id of first object
* @param lastId
* Id of last object
* @param hasMore
* Denotes if there are more object available
*/
* Always "list"
* @param data
* A list of vector store objects.
* @param firstId
* Id of first object
* @param lastId
* Id of last object
* @param hasMore
* Denotes if there are more object available
*/
case class ListVectorStoresResponse(
`object`: String = "list",
data: Seq[VectorStore],
Expand All @@ -111,13 +111,13 @@ object VectorStoreResponseData {
}

/** @param id
* Id of deleted object
* @param `object`
* vector_store.deleted
* @param deleted
* boolean describing whether or not operation was successful
* For more information please visit: [[https://platform.openai.com/docs/api-reference/assistants/deleteAssistant]]
*/
* Id of deleted object
* @param `object`
* vector_store.deleted
* @param deleted
* boolean describing whether or not operation was successful For more information please visit:
* [[https://platform.openai.com/docs/api-reference/assistants/deleteAssistant]]
*/
case class DeleteVectorStoreResponse(
id: String,
`object`: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@ object FileStatus {
.bimap[FileStatus](
{
case InProgress => "in_progress"
case Completed => "completed"
case Failed => "failed"
case Cancelled => "cancelled"
case Completed => "completed"
case Failed => "failed"
case Cancelled => "cancelled"
},
json => {
json =>
json.str match {
case "in_progress" => InProgress
case "completed" => Completed
case "failed" => Failed
case "cancelled" => Cancelled
case "completed" => Completed
case "failed" => Failed
case "cancelled" => Cancelled
}
}
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ object VectorStoreFileResponseData {
}

/** @param object
* Always "list"
* @param data
* A list of vector store file objects.
* @param firstId
* Id of first object
* @param lastId
* Id of last object
* @param hasMore
* Denotes if there are more object available
*/
* Always "list"
* @param data
* A list of vector store file objects.
* @param firstId
* Id of first object
* @param lastId
* Id of last object
* @param hasMore
* Denotes if there are more object available
*/
case class ListVectorStoreFilesResponse(
`object`: String = "list",
data: Seq[VectorStoreFile],
Expand All @@ -88,14 +88,15 @@ object VectorStoreFileResponseData {
implicit val listVectorStoreFilesResponseR: SnakePickle.Reader[ListVectorStoreFilesResponse] =
SnakePickle.macroR[ListVectorStoreFilesResponse]
}

/** @param id
* Id of deleted object
* @param `object`
* vector_store.file.deleted
* @param deleted
* boolean describing whether or not operation was successful
* For more information please visit: [[https://platform.openai.com/docs/api-reference/assistants/deleteAssistant]]
*/
* Id of deleted object
* @param `object`
* vector_store.file.deleted
* @param deleted
* boolean describing whether or not operation was successful For more information please visit:
* [[https://platform.openai.com/docs/api-reference/assistants/deleteAssistant]]
*/
case class DeleteVectorStoreFileResponse(
id: String,
`object`: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ModerationsDataSpec extends AnyFlatSpec with Matchers with EitherValues {
SttpUpickleApiExtension.deserializeJsonSnake[ModerationData].apply(createModerationResponse)

// then
givenResponse.value.model shouldBe ModerationModel.CustomModerationModel("text-moderation-007")
givenResponse.value.model shouldBe ModerationModel.CustomModerationModel("text-moderation-007")
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import org.scalatest.matchers.should.Matchers
import sttp.openai.fixtures.VectorStoreFixture
import sttp.openai.json.{SnakePickle, SttpUpickleApiExtension}
import sttp.openai.requests.vectorstore.VectorStoreRequestBody.{CreateVectorStoreBody, ModifyVectorStoreBody}
import sttp.openai.requests.vectorstore.VectorStoreResponseData.{Completed, DeleteVectorStoreResponse, FileCounts, InProgress, ListVectorStoresResponse, VectorStore}
import sttp.openai.requests.vectorstore.VectorStoreResponseData.{
Completed,
DeleteVectorStoreResponse,
FileCounts,
InProgress,
ListVectorStoresResponse,
VectorStore
}

class VectorStoreDataSpec extends AnyFlatSpec with Matchers with EitherValues {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ import org.scalatest.matchers.should.Matchers
import sttp.openai.fixtures.VectorStoreFileFixture
import sttp.openai.json.{SnakePickle, SttpUpickleApiExtension}
import sttp.openai.requests.vectorstore.file.VectorStoreFileRequestBody.{CreateVectorStoreFileBody, ListVectorStoreFilesBody}
import sttp.openai.requests.vectorstore.file.VectorStoreFileResponseData.{DeleteVectorStoreFileResponse, LastError, ListVectorStoreFilesResponse, RateLimitExceeded, ServerError, VectorStoreFile}
import sttp.openai.requests.vectorstore.file.VectorStoreFileResponseData.{
DeleteVectorStoreFileResponse,
LastError,
ListVectorStoreFilesResponse,
RateLimitExceeded,
ServerError,
VectorStoreFile
}

class VectorStoreFileDataSpec extends AnyFlatSpec with Matchers with EitherValues {

Expand Down
Loading

0 comments on commit ed3b4e7

Please sign in to comment.