Fix OpenAI file updating
authorLanius Trolling <lanius@laniustrolling.dev>
Mon, 13 May 2024 22:50:22 +0000 (18:50 -0400)
committerLanius Trolling <lanius@laniustrolling.dev>
Mon, 13 May 2024 22:50:22 +0000 (18:50 -0400)
src/jvmMain/kotlin/info/mechyrdia/lore/ViewsRobots.kt
src/jvmMain/kotlin/info/mechyrdia/robot/RobotApi.kt
src/jvmMain/kotlin/info/mechyrdia/robot/RobotService.kt

index 76a2cb234b46d1f9b0bfccea1b14735837593b02..efd41e78b5c1e8dffa8f959f943f81f8fc85c76c 100644 (file)
@@ -3,6 +3,7 @@ package info.mechyrdia.lore
 import info.mechyrdia.MainDomainName
 import info.mechyrdia.data.*
 import java.time.Instant
+import java.time.ZoneId
 import java.time.format.DateTimeFormatter
 
 private val AVERAGE_FACTBOOK_INTRO_CHANGEFREQ = SitemapChangeFrequency.DAILY
@@ -24,7 +25,7 @@ val SitemapChangeFrequency.xmlValue: String
        get() = name.lowercase()
 
 val Instant.xmlValue: String
-       get() = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this)
+       get() = DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(atZone(ZoneId.of("Z")))
 
 val Double.xmlValue: String
        get() = "%f".format(this)
index becd998b9fb5b735b4dd08e77ee722394ba9e957..627e52288b9bf04d58dadcc63345f61923693947 100644 (file)
@@ -34,15 +34,15 @@ value class RobotClient(
                "https://api.openai.com/v1/files/${fileId.id}"
        ).body<RobotFileDeletionResponse>()
        
-       suspend fun downloadFile(fileId: RobotFileId) = client.delete(
-               "https://api.openai.com/v1/files/${fileId.id}"
+       suspend fun downloadFile(fileId: RobotFileId) = client.get(
+               "https://api.openai.com/v1/files/${fileId.id}/content"
        ).body<ByteArray>()
        
        suspend fun createVectorStore(request: RobotCreateVectorStoreRequest) = client.post("https://api.openai.com/v1/vector_stores") {
                setJsonBody(request)
        }.body<RobotVectorStore>()
        
-       suspend fun addFileToVectorStore(vsId: RobotVectorStoreId, fileId: RobotFileId) = client.post("https://api.openai.com/v1/vector_stores/${vsId.id}") {
+       suspend fun addFileToVectorStore(vsId: RobotVectorStoreId, fileId: RobotFileId) = client.post("https://api.openai.com/v1/vector_stores/${vsId.id}/files") {
                setJsonBody(RobotAddFileToVectorStoreRequest(fileId))
        }.body<RobotVectorStoreFile>()
        
index ce01519226553cf4fa1b5cdc6fe8f24903aaf700..80f640c3fb1a9c6744e11e7856c10a3c9cfef876 100644 (file)
@@ -184,7 +184,7 @@ class RobotService(
                        robotGlobals = robotGlobals.copy(
                                assistantId = robotClient.createAssistant(
                                        RobotCreateAssistantRequest(
-                                               model = "gpt-4-turbo",
+                                               model = "gpt-4o",
                                                name = "Natural-language Universal Knowledge Engine",
                                                instructions = "You are a helpful interactive encyclopedia, able to answer questions with information from the provided files",
                                                tools = listOf(