Skip to content

Commit 8158941

Browse files
committed
Reformatting mostly
1 parent 2d00fe4 commit 8158941

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

anthropic-client/src/main/scala/io/cequence/openaiscala/domain/settings/CreateChatCompletionSettingsOps.scala

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,23 @@ object CreateChatCompletionSettingsOps {
77
private val AnthropicCachedUserMessagesCount = "cached_user_messages_count"
88
private val AnthropicUseSystemMessagesCache = "use_system_messages_cache"
99

10+
def setAnthropicCachedUserMessagesCount(count: Int): CreateChatCompletionSettings =
11+
settings.copy(
12+
extra_params = settings.extra_params + (AnthropicCachedUserMessagesCount -> count)
13+
)
14+
15+
def setUseAnthropicSystemMessagesCache(useCache: Boolean): CreateChatCompletionSettings =
16+
settings.copy(
17+
extra_params = settings.extra_params + (AnthropicUseSystemMessagesCache -> useCache)
18+
)
19+
1020
def anthropicCachedUserMessagesCount: Int =
1121
settings.extra_params
1222
.get(AnthropicCachedUserMessagesCount)
13-
.flatMap(numberAsString => Try(numberAsString.toString.toInt).toOption)
23+
.flatMap {
24+
case value: Int => Some(value)
25+
case value: Any => Try(value.toString.toInt).toOption
26+
}
1427
.getOrElse(0)
1528

1629
def useAnthropicSystemMessagesCache: Boolean =

openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateChatCompletionCachedWithOpenAIAdapter.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import scala.concurrent.Future
1111
object AnthropicCreateChatCompletionCachedWithOpenAIAdapter
1212
extends ExampleBase[OpenAIChatCompletionService] {
1313

14-
override val service: OpenAIChatCompletionService = ChatCompletionProvider.anthropic(withCache = true)
14+
override val service: OpenAIChatCompletionService =
15+
ChatCompletionProvider.anthropic(withCache = true)
1516

1617
private val messages = Seq(
1718
SystemMessage("You are a helpful assistant."),

openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/AnthropicCreateChatCompletionStreamedWithOpenAIAdapter.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ object AnthropicCreateChatCompletionStreamedWithOpenAIAdapter
1818

1919
private val logger = LoggerFactory.getLogger(this.getClass)
2020

21-
override val service: OpenAIChatCompletionStreamedService = ChatCompletionProvider.anthropic()
21+
override val service: OpenAIChatCompletionStreamedService =
22+
ChatCompletionProvider.anthropic()
2223

2324
private val messages = Seq(
2425
SystemMessage("You are a helpful assistant."),

openai-examples/src/main/scala/io/cequence/openaiscala/examples/nonopenai/ChatCompletionProvider.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ object ChatCompletionProvider {
8383
* Requires `ANTHROPIC_API_KEY`
8484
*/
8585
def anthropic(
86-
withCache: Boolean = false)(
86+
withCache: Boolean = false
87+
)(
8788
implicit ec: ExecutionContext,
8889
m: Materializer
8990
): OpenAIChatCompletionStreamedService =

0 commit comments

Comments
 (0)