Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ insert_final_newline = true
trim_trailing_whitespace = false

[*.java]
indent_size = 4
indent_size = tab
tab_width = 4
ij_java_names_count_to_use_import_on_demand = 2147483647
ij_java_packages_to_use_import_on_demand = unset

# noinspection EditorConfigKeyCorrectness
[*.{kt,kts}]
indent_size = 4
indent_size = tab
tab_width = 4
max_line_length = 100
ij_kotlin_name_count_to_use_star_import = 2147483647
ij_kotlin_name_count_to_use_star_import_for_members = 2147483647
Expand All @@ -36,8 +38,9 @@ ktlint_function_naming_ignore_when_annotated_with = "Test"
max_line_length = off
ij_kotlin_name_count_to_use_star_import = unset
ij_kotlin_name_count_to_use_star_import_for_members = unset
ij_kotlin_packages_to_use_import_on_demand = kotlinx.serialization,kotlinx.serialization.descriptors,kotlinx.serialization.encoding
ij_kotlin_packages_to_use_import_on_demand = kotlinx.serialization, kotlinx.serialization.descriptors, kotlinx.serialization.encoding
insert_final_newline = unset
# no-trailing-spaces:
# in
# standard:no-multi-spaces: 2

[*.xml]
tab_width = 4
indent_size = tab
11 changes: 10 additions & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,15 @@ jobs:
caches/keyrings

- name: Build with Gradle
run: gradle clean build dokkaGenerate dokkaJavadocJar sourcesJar koverXmlReport
run: |
./gradlew \
--rerun-tasks --no-daemon \
-Dorg.gradle.maven.repo.local=.m2-local \
clean build publishToMavenLocal koverXmlReport

- name: OpenAI Maven Integration Tests
working-directory: ai-mocks-openai/samples/shadow
run: mvn --batch-mode test

Comment on lines +63 to 66
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Align Maven test JDK with POM (Java 17).

The Maven step currently runs on JDK 24. Set up Java 17 before mvn test to match <maven.compiler.release>.

+      - name: Set up JDK 17 for Maven sample
+        uses: actions/setup-java@v5
+        with:
+          java-version: 17
+          distribution: 'temurin'
       - name: OpenAI Maven Integration Tests
         working-directory: ai-mocks-openai/samples/shadow
         run: mvn --batch-mode test
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: OpenAI Maven Integration Tests
working-directory: ai-mocks-openai/samples/shadow
run: mvn --batch-mode test
- name: Set up JDK 17 for Maven sample
uses: actions/setup-java@v5
with:
java-version: 17
distribution: 'temurin'
- name: OpenAI Maven Integration Tests
working-directory: ai-mocks-openai/samples/shadow
run: mvn --batch-mode test
🤖 Prompt for AI Agents
.github/workflows/gradle.yml around lines 59 to 62: the Maven integration-test
step runs under JDK 24 while the project POM compiles for Java 17; add a setup
step immediately before the mvn --batch-mode test to install and configure Java
17 (for example using actions/setup-java with java-version: '17' and an
appropriate distribution like temurin) so the mvn test runs using Java 17 and
matches <maven.compiler.release>.

- name: Publish Test Report
uses: mikepenz/action-junit-report@v5
Expand All @@ -81,6 +89,7 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
slug: mokksy/ai-mocks


dependency-submission:

runs-on: ubuntu-latest
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.PHONY: build
build:
./gradlew clean build dokkaJavadocJar sourcesJar koverHtmlReport
rm -rf ~/.m2/repository/me/kpavlov/aimocks ~/.m2/repository/me/kpavlov/mokksy && \
./gradlew --rerun-tasks clean build publishToMavenLocal koverHtmlReport && \
(cd ai-mocks-openai/samples/shadow && mvn test)

.PHONY: test
test:
Expand Down Expand Up @@ -43,7 +45,7 @@ pom:
.PHONY: publish
publish:
rm -rf ~/.m2/repository/me/kpavlov/aimocks ~/.m2/repository/me/kpavlov/mokksy
./gradlew clean build check sourcesJar publishToMavenLocal
./gradlew --rerun-tasks clean build check sourcesJar publishToMavenLocal
echo "Publishing 📢"
## https://vanniktech.github.io/gradle-maven-publish-plugin/central/#configuring-maven-central
# ./gradlew publishToMavenCentral \
Expand Down
2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
SONATYPE_PASSWORD=...

./gradlew clean build sourcesJar check publishToMavenCentral \
--stacktrace --warning-mode=all \
--stacktrace --rerun-tasks --warning-mode=all \
-PmavenCentralUsername="$SONATYPE_USERNAME" \
-PmavenCentralPassword="$SONATYPE_PASSWORD"
```
Expand Down
16 changes: 16 additions & 0 deletions ai-mocks-a2a/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
`dokka-convention`
`publish-convention`
`netty-convention`
`shadow-convention`
}

dokka {
Expand Down Expand Up @@ -63,3 +64,18 @@ kotlin {
}
}
}

publishing {
publications {
create<MavenPublication>("shadow") {
artifactId = "${project.name}-standalone"
artifact(tasks.named("shadowJar")) {
classifier = ""
extension = "jar"
}
artifact(tasks["jvmSourcesJar"]) {
classifier = "sources"
}
}
}
}
16 changes: 16 additions & 0 deletions ai-mocks-anthropic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
`kotlin-convention`
`dokka-convention`
`publish-convention`
`shadow-convention`
}

dokka {
Expand Down Expand Up @@ -57,3 +58,18 @@ kotlin {
}
}
}

publishing {
publications {
create<MavenPublication>("shadow") {
artifactId = "${project.name}-standalone"
artifact(tasks.named("shadowJar")) {
classifier = ""
extension = "jar"
}
artifact(tasks["jvmSourcesJar"]) {
classifier = "sources"
}
}
}
}
16 changes: 16 additions & 0 deletions ai-mocks-gemini/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
`kotlin-convention`
`dokka-convention`
`publish-convention`
`shadow-convention`
}

dokka {
Expand Down Expand Up @@ -56,3 +57,18 @@ kotlin {
}
}
}

publishing {
publications {
create<MavenPublication>("shadow") {
artifactId = "${project.name}-standalone"
artifact(tasks.named("shadowJar")) {
classifier = ""
extension = "jar"
}
artifact(tasks["jvmSourcesJar"]) {
classifier = "sources"
}
}
}
}
16 changes: 16 additions & 0 deletions ai-mocks-ollama/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ plugins {
`kotlin-convention`
`dokka-convention`
`publish-convention`
`shadow-convention`
}

kotlin {
Expand Down Expand Up @@ -62,3 +63,18 @@ kotlin {
}
}
}

publishing {
publications {
create<MavenPublication>("shadow") {
artifactId = "${project.name}-standalone"
artifact(tasks.named("shadowJar")) {
classifier = ""
extension = "jar"
}
artifact(tasks["jvmSourcesJar"]) {
classifier = "sources"
}
}
}
}
16 changes: 16 additions & 0 deletions ai-mocks-openai/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ plugins {
`dokka-convention`
`publish-convention`
`netty-convention`
`shadow-convention`
// id("org.openapi.generator") version "7.12.0"
}

Expand Down Expand Up @@ -59,3 +60,18 @@ kotlin {
}
}
}

publishing {
publications {
create<MavenPublication>("shadow") {
artifactId = "${project.name}-standalone"
artifact(tasks.named("shadowJar")) {
classifier = ""
extension = "jar"
}
artifact(tasks["jvmSourcesJar"]) {
classifier = "sources"
}
}
}
}
75 changes: 38 additions & 37 deletions ai-mocks-openai/samples/OpenaiLc4jSample.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"metadata": {
"collapsed": true,
"ExecuteTime": {
"end_time": "2025-09-19T19:49:09.868118Z",
"start_time": "2025-09-19T19:49:05.225077Z"
"end_time": "2025-09-21T08:33:23.068468Z",
"start_time": "2025-09-21T08:33:22.912180Z"
}
},
"source": [
Expand All @@ -23,21 +23,21 @@
" mavenCentral()\n",
" }\n",
" dependencies(\n",
" \"me.kpavlov.aimocks:ai-mocks-openai-jvm:0.5.0-SNAPSHOT\",\n",
" \"me.kpavlov.aimocks:ai-mocks-openai-standalone:0.5.0-SNAPSHOT\",\n",
" \"io.kotest:kotest-assertions-core:5.9.1\",\n",
" \"io.kotest:kotest-assertions-json:5.9.1\",\n",
" \"dev.langchain4j:langchain4j-open-ai:1.5.0\",\n",
" \"dev.langchain4j:langchain4j-kotlin:1.5.0-beta11\",\n",
" )\n",
"}"
],
"outputs": [],
"execution_count": 10
"execution_count": 3
},
{
"metadata": {
"ExecuteTime": {
"end_time": "2025-09-19T19:49:09.960056Z",
"start_time": "2025-09-19T19:49:09.877363Z"
"end_time": "2025-09-21T08:33:27.746433Z",
"start_time": "2025-09-21T08:33:27.667009Z"
}
},
"cell_type": "code",
Expand All @@ -51,7 +51,7 @@
"import io.kotest.matchers.shouldBe\n",
"import io.kotest.matchers.shouldNotBe\n",
"\n",
"val openai = MockOpenai(verbose = true)\n",
"val openai = MockOpenai(verbose = true, port = 0)\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix MockOpenai ctor call (named-arg mismatch in REPL).

Use positional args to match (port: Int, verbose: Boolean).

-val openai = MockOpenai(verbose = true, port = 0)
+val openai = MockOpenai(0, true)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"val openai = MockOpenai(verbose = true, port = 0)\n",
val openai = MockOpenai(0, true)
🤖 Prompt for AI Agents
In ai-mocks-openai/samples/OpenaiLc4jSample.ipynb around line 54, the MockOpenai
constructor is being called with named args in the wrong order for the REPL;
change the call to use positional arguments so the first value is the port (Int)
and the second is verbose (Boolean) — e.g., pass the port first and the verbose
flag second instead of using named parameters.

"\n",
"val model: OpenAiChatModel =\n",
" OpenAiChatModel\n",
Expand All @@ -61,8 +61,8 @@
" .build()\n",
"\n",
"openai.completion {\n",
" temperature = 0.42\n",
" seed = 100500\n",
"// temperature(0.42) = 0.42\n",
"// seed = 100500\n",
" model = \"4o\"\n",
" maxTokens = 120\n",
"} responds {\n",
Expand Down Expand Up @@ -96,31 +96,34 @@
],
"outputs": [
{
"ename": "java.lang.NoClassDefFoundError",
"evalue": "io/ktor/server/plugins/contentnegotiation/ContentNegotiationConfig",
"ename": "org.jetbrains.kotlinx.jupyter.exceptions.ReplCompilerException",
"evalue": "at Cell In[4], line 3, column 35: Unresolved reference: chat\nat Cell In[4], line 10, column 14: None of the following functions can be called with the arguments supplied: \npublic constructor MockOpenai() defined in me.kpavlov.aimocks.openai.MockOpenai\npublic constructor MockOpenai(port: Int, verbose: Boolean) defined in me.kpavlov.aimocks.openai.MockOpenai\nat Cell In[4], line 20, column 3: Unresolved reference: temperature\nat Cell In[4], line 21, column 3: Unresolved reference: seed\nat Cell In[4], line 22, column 3: Val cannot be reassigned\nat Cell In[4], line 22, column 11: Type mismatch: inferred type is String but OpenAiChatModel was expected\nat Cell In[4], line 23, column 3: Unresolved reference: maxTokens\nat Cell In[4], line 25, column 3: Unresolved reference: assistantContent\nat Cell In[4], line 26, column 3: Unresolved reference: finishReason\nat Cell In[4], line 32, column 11: None of the following functions can be called with the arguments supplied: \npublic open fun chat(p0: ChatRequest!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel\npublic open fun chat(vararg p0: ChatMessage!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel\npublic open fun chat(p0: String!): String! defined in dev.langchain4j.model.openai.OpenAiChatModel\npublic open fun chat(p0: (Mutable)List<ChatMessage!>!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel\nat Cell In[4], line 33, column 7: Unresolved reference: parameters\nat Cell In[4], line 41, column 7: Unresolved reference: messages\nat Cell In[4], line 41, column 16: Unresolved reference: +=\nat Cell In[4], line 45, column 5: Unresolved reference: finishReason\nat Cell In[4], line 46, column 5: Unresolved reference: tokenUsage\nat Cell In[4], line 47, column 5: Unresolved reference: aiMessage",
"output_type": "error",
"traceback": [
"java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationConfig",
"\tat me.kpavlov.aimocks.openai.MockOpenai.<init>(MockOpenai.kt:33)",
"\tat me.kpavlov.aimocks.openai.MockOpenai.<init>(MockOpenai.kt:27)",
"\tat Line_24_jupyter.<init>(Line_24.jupyter.kts:10) at Cell In[11], line 10",
"\tat java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)",
"\tat java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)",
"\tat java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)",
"\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.evalWithConfigAndOtherScriptsResults(BasicJvmScriptEvaluator.kt:122)",
"\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke$suspendImpl(BasicJvmScriptEvaluator.kt:48)",
"\tat kotlin.script.experimental.jvm.BasicJvmScriptEvaluator.invoke(BasicJvmScriptEvaluator.kt)",
"\tat kotlin.script.experimental.jvm.BasicJvmReplEvaluator.eval(BasicJvmReplEvaluator.kt:49)",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl$eval$resultWithDiagnostics$1.invokeSuspend(InternalEvaluatorImpl.kt:137)",
"\tat kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)",
"\tat kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)",
"\tat kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)",
"\tat kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)",
"\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)",
"\tat kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)",
"\tat kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:47)",
"\tat kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:137)",
"org.jetbrains.kotlinx.jupyter.exceptions.ReplCompilerException: at Cell In[4], line 3, column 35: Unresolved reference: chat",
"at Cell In[4], line 10, column 14: None of the following functions can be called with the arguments supplied: ",
"public constructor MockOpenai() defined in me.kpavlov.aimocks.openai.MockOpenai",
"public constructor MockOpenai(port: Int, verbose: Boolean) defined in me.kpavlov.aimocks.openai.MockOpenai",
"at Cell In[4], line 20, column 3: Unresolved reference: temperature",
"at Cell In[4], line 21, column 3: Unresolved reference: seed",
"at Cell In[4], line 22, column 3: Val cannot be reassigned",
"at Cell In[4], line 22, column 11: Type mismatch: inferred type is String but OpenAiChatModel was expected",
"at Cell In[4], line 23, column 3: Unresolved reference: maxTokens",
"at Cell In[4], line 25, column 3: Unresolved reference: assistantContent",
"at Cell In[4], line 26, column 3: Unresolved reference: finishReason",
"at Cell In[4], line 32, column 11: None of the following functions can be called with the arguments supplied: ",
"public open fun chat(p0: ChatRequest!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel",
"public open fun chat(vararg p0: ChatMessage!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel",
"public open fun chat(p0: String!): String! defined in dev.langchain4j.model.openai.OpenAiChatModel",
"public open fun chat(p0: (Mutable)List<ChatMessage!>!): ChatResponse! defined in dev.langchain4j.model.openai.OpenAiChatModel",
"at Cell In[4], line 33, column 7: Unresolved reference: parameters",
"at Cell In[4], line 41, column 7: Unresolved reference: messages",
"at Cell In[4], line 41, column 16: Unresolved reference: +=",
"at Cell In[4], line 45, column 5: Unresolved reference: finishReason",
"at Cell In[4], line 46, column 5: Unresolved reference: tokenUsage",
"at Cell In[4], line 47, column 5: Unresolved reference: aiMessage",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.JupyterCompilerImpl.compileSync(JupyterCompilerImpl.kt:151)",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.InternalEvaluatorImpl.eval(InternalEvaluatorImpl.kt:126)",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute_L4Nmkdk$lambda$0$0(CellExecutorImpl.kt:80)",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.ReplForJupyterImpl.withHost(ReplForJupyterImpl.kt:791)",
"\tat org.jetbrains.kotlinx.jupyter.repl.impl.CellExecutorImpl.execute-L4Nmkdk(CellExecutorImpl.kt:78)",
Expand All @@ -147,13 +150,11 @@
"\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl$Task.execute(JupyterExecutorImpl.kt:41)",
"\tat org.jetbrains.kotlinx.jupyter.execution.JupyterExecutorImpl.executorThread$lambda$0(JupyterExecutorImpl.kt:81)",
"\tat kotlin.concurrent.ThreadsKt$thread$thread$1.run(Thread.kt:30)",
"",
"java.lang.NoClassDefFoundError: io/ktor/server/plugins/contentnegotiation/ContentNegotiationConfig",
"at Cell In[11], line 10"
""
]
}
],
"execution_count": 11
"execution_count": 4
}
],
"metadata": {
Expand Down
Loading
Loading