-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
one more refactoring, Content moved to content package, also system p…
…rompt serialization fixed and test case added.
- Loading branch information
Showing
13 changed files
with
98 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.xemantic.anthropic.content | ||
|
||
import com.xemantic.anthropic.cache.CacheControl | ||
import kotlinx.serialization.ExperimentalSerializationApi | ||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.json.JsonClassDiscriminator | ||
|
||
@Serializable | ||
@JsonClassDiscriminator("type") | ||
@OptIn(ExperimentalSerializationApi::class) | ||
abstract class Content { | ||
|
||
@SerialName("cache_control") | ||
abstract val cacheControl: CacheControl? | ||
|
||
} | ||
|
||
interface ContentBuilder { | ||
|
||
val content: MutableList<Content> | ||
|
||
operator fun Content.unaryPlus() { | ||
content += this | ||
} | ||
|
||
operator fun String.unaryPlus() { | ||
content += Text(this) | ||
} | ||
|
||
operator fun Collection<Content>.unaryPlus() { | ||
content += this | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.xemantic.anthropic.content | ||
|
||
import com.xemantic.anthropic.Anthropic | ||
import com.xemantic.anthropic.message.Message | ||
import kotlinx.coroutines.runBlocking | ||
|
||
fun main() = runBlocking { | ||
val client = Anthropic { | ||
anthropicBeta = "pdfs-2024-09-25" | ||
} | ||
|
||
val response = client.messages.create { | ||
+Message { | ||
+Document("/home/morisil/Downloads/Kazik_Pogoda-cv-2025-10-28.pdf") | ||
+"Extract data from this PDF and return it as a markdown" | ||
} | ||
} | ||
|
||
println(response) | ||
} |