Skip to content
This repository was archived by the owner on Jan 24, 2026. It is now read-only.

Commit 95a50fe

Browse files
authored
Merge pull request #15 from Stream29/feat/endpoint-api-show
feat: endpoint-api-show
2 parents 6758b52 + 4301a7a commit 95a50fe

File tree

4 files changed

+147
-20
lines changed

4 files changed

+147
-20
lines changed

.run/Run To Collect Metadata.run.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<option name="ALTERNATIVE_JRE_PATH" value="graalvm-ce-21" />
44
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
55
<option name="MAIN_CLASS_NAME" value="io.github.stream29.proxy.MainKt" />
6-
<module name="OpenAI2LmStudioProxy.main" />
6+
<module name="ProxyAsLocalModel.main" />
77
<option name="VM_PARAMETERS" value="-agentlib:native-image-agent=config-output-dir=src\main\resources\META-INF\native-image" />
88
<extension name="coverage">
99
<pattern>
@@ -19,7 +19,7 @@
1919
<option name="programParameters" value="" />
2020
<option name="shortenCommandLine" />
2121
<option name="vmParameters" value="-agentlib:native-image-agent=config-output-dir=src\main\resources\META-INF\native-image" />
22-
<option name="workingDirectory" value="E:\ACodeSpace\local\OpenAI2LmStudioProxy\OpenAI2LmStudioProxy" />
22+
<option name="workingDirectory" value="E:\ACodeSpace\push\ProxyAsLocalModel" />
2323
<method v="2">
2424
<option name="Make" enabled="true" />
2525
</method>

src/main/kotlin/io/github/stream29/proxy/server/ConfigureServer.kt

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import io.ktor.server.plugins.statuspages.*
1515
import io.ktor.server.request.*
1616
import io.ktor.server.response.*
1717
import io.ktor.server.routing.*
18+
import kotlinx.serialization.json.*
1819
import org.slf4j.Logger
1920
import org.slf4j.event.Level
2021

@@ -86,8 +87,11 @@ fun createOllamaServer(config: OllamaConfig): EmbeddedServer<CIOApplicationEngin
8687
apiProvider.generateOStream(requestWithOriginalModelName),
8788
)
8889
}
90+
post("/api/show") {
91+
call.receiveText()
92+
call.respond(mockOModelInfoResponse)
93+
}
8994
}
90-
9195
}
9296
}
9397

@@ -108,3 +112,40 @@ private fun Application.configureServerCommon(callLogger: Logger) {
108112
}
109113
}
110114
}
115+
116+
private val mockOModelInfoResponse = buildJsonObject {
117+
put("modelfile", "Mock modelfile")
118+
put("parameters", "Mock parameters")
119+
put("template", "Mock template")
120+
putJsonObject("details") {
121+
put("parent_model", "")
122+
put("format", "gguf")
123+
put("family", "llama")
124+
putJsonArray("families") { add("llama") }
125+
put("parameter_size", "8.0B")
126+
put("quantization_level", "Q4_0")
127+
}
128+
putJsonObject("model_info") {
129+
put("general.architecture", "llama")
130+
put("general.file_type", 2)
131+
put("general.parameter_count", 8030261248L)
132+
put("general.quantization_version", 2)
133+
put("llama.attention.head_count", 32)
134+
put("llama.attention.head_count_kv", 8)
135+
put("llama.attention.layer_norm_rms_epsilon", 0.00001)
136+
put("llama.block_count", 32)
137+
put("llama.context_length", 8192)
138+
put("llama.embedding_length", 4096)
139+
put("llama.feed_forward_length", 14336)
140+
put("llama.rope.dimension_count", 128)
141+
put("llama.rope.freq_base", 500000)
142+
put("llama.vocab_size", 128256)
143+
put("tokenizer.ggml.bos_token_id", 128000)
144+
put("tokenizer.ggml.eos_token_id", 128009)
145+
putJsonArray("tokenizer.ggml.merges") {}
146+
put("tokenizer.ggml.model", "gpt2")
147+
put("tokenizer.ggml.pre", "llama-bpe")
148+
putJsonArray("tokenizer.ggml.token_type") {}
149+
putJsonArray("tokenizer.ggml.tokens") {}
150+
}
151+
}

src/main/resources/META-INF/native-image/reflect-config.json

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@
150150
"name":"com.sun.crypto.provider.HmacCore$HmacSHA256",
151151
"methods":[{"name":"<init>","parameterTypes":[] }]
152152
},
153+
{
154+
"name":"com.sun.crypto.provider.HmacCore$HmacSHA384",
155+
"methods":[{"name":"<init>","parameterTypes":[] }]
156+
},
153157
{
154158
"name":"com.sun.management.GarbageCollectorMXBean",
155159
"queryAllPublicMethods":true
@@ -275,18 +279,39 @@
275279
"name":"io.ktor.client.engine.cio.Endpoint",
276280
"fields":[{"name":"connections"}]
277281
},
282+
{
283+
"name":"io.ktor.client.plugins.HttpRetryDelayContext"
284+
},
285+
{
286+
"name":"io.ktor.client.plugins.HttpRetryModifyRequestContext"
287+
},
288+
{
289+
"name":"io.ktor.client.plugins.HttpRetryShouldRetryContext"
290+
},
278291
{
279292
"name":"io.ktor.client.plugins.HttpSend"
280293
},
294+
{
295+
"name":"io.ktor.client.plugins.HttpTimeoutConfig"
296+
},
281297
{
282298
"name":"io.ktor.client.plugins.api.ClientPluginImpl"
283299
},
284300
{
285301
"name":"io.ktor.client.plugins.api.ClientPluginInstance"
286302
},
303+
{
304+
"name":"io.ktor.client.request.HttpRequest"
305+
},
306+
{
307+
"name":"io.ktor.client.request.HttpRequestBuilder"
308+
},
287309
{
288310
"name":"io.ktor.client.request.ResponseAdapter"
289311
},
312+
{
313+
"name":"io.ktor.client.statement.HttpResponse"
314+
},
290315
{
291316
"name":"io.ktor.http.ContentType"
292317
},
@@ -296,9 +321,6 @@
296321
{
297322
"name":"io.ktor.http.content.ChannelWriterContent"
298323
},
299-
{
300-
"name":"io.ktor.http.content.TextContent"
301-
},
302324
{
303325
"name":"io.ktor.network.selector.InterestSuspensionsMap",
304326
"fields":[{"name":"acceptHandlerReference"}, {"name":"connectHandlerReference"}, {"name":"readHandlerReference"}, {"name":"writeHandlerReference"}]
@@ -319,9 +341,6 @@
319341
"name":"io.ktor.network.sockets.SocketBase",
320342
"fields":[{"name":"actualCloseFlag"}, {"name":"closeFlag"}, {"name":"readerJob"}, {"name":"writerJob"}]
321343
},
322-
{
323-
"name":"io.ktor.server.application.ApplicationCall"
324-
},
325344
{
326345
"name":"io.ktor.server.application.PluginInstance"
327346
},
@@ -429,6 +448,9 @@
429448
"name":"java.lang.Thread",
430449
"fields":[{"name":"threadLocalRandomProbe"}]
431450
},
451+
{
452+
"name":"java.lang.Throwable"
453+
},
432454
{
433455
"name":"java.lang.Void",
434456
"fields":[{"name":"TYPE"}]
@@ -563,6 +585,10 @@
563585
"name":"java.util.concurrent.atomic.AtomicBoolean",
564586
"fields":[{"name":"value"}]
565587
},
588+
{
589+
"name":"java.util.concurrent.atomic.AtomicMarkableReference",
590+
"fields":[{"name":"pair"}]
591+
},
566592
{
567593
"name":"java.util.concurrent.atomic.AtomicReference",
568594
"fields":[{"name":"value"}]
@@ -682,6 +708,15 @@
682708
{
683709
"name":"kotlin.Boolean"
684710
},
711+
{
712+
"name":"kotlin.Function2"
713+
},
714+
{
715+
"name":"kotlin.Function3"
716+
},
717+
{
718+
"name":"kotlin.Int"
719+
},
685720
{
686721
"name":"kotlin.Long"
687722
},
@@ -694,9 +729,6 @@
694729
"name":"kotlin.SafePublicationLazyImpl",
695730
"fields":[{"name":"_value"}]
696731
},
697-
{
698-
"name":"kotlin.String"
699-
},
700732
{
701733
"name":"kotlin.Throwable"
702734
},
@@ -713,7 +745,10 @@
713745
"name":"kotlin.collections.MutableMap"
714746
},
715747
{
716-
"name":"kotlin.coroutines.jvm.internal.BaseContinuationImpl"
748+
"name":"kotlin.jvm.functions.Function2"
749+
},
750+
{
751+
"name":"kotlin.jvm.functions.Function3"
717752
},
718753
{
719754
"name":"kotlin.jvm.internal.DefaultConstructorMarker"
@@ -786,9 +821,6 @@
786821
"name":"kotlinx.coroutines.internal.Segment",
787822
"fields":[{"name":"cleanedAndPointers$volatile"}]
788823
},
789-
{
790-
"name":"kotlinx.coroutines.internal.StackTraceRecoveryKt"
791-
},
792824
{
793825
"name":"kotlinx.coroutines.internal.ThreadSafeHeap",
794826
"fields":[{"name":"_size$volatile"}]
@@ -820,6 +852,14 @@
820852
{
821853
"name":"kotlinx.io.Source"
822854
},
855+
{
856+
"name":"kotlinx.serialization.json.JsonObject",
857+
"fields":[{"name":"Companion"}]
858+
},
859+
{
860+
"name":"kotlinx.serialization.json.JsonObject$Companion",
861+
"methods":[{"name":"serializer","parameterTypes":[] }]
862+
},
823863
{
824864
"name":"sun.management.ClassLoadingImpl",
825865
"queryAllPublicConstructors":true

src/main/resources/META-INF/native-image/resource-config.json

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@
228228
"pattern":"\\Qio/github/stream29/jsonschemagenerator\\E"
229229
}, {
230230
"pattern":"\\Qio/github/stream29/proxy/client\\E"
231+
}, {
232+
"pattern":"\\Qio/github/stream29/proxy/relocate/com/aallam/openai/api/chat\\E"
233+
}, {
234+
"pattern":"\\Qio/github/stream29/proxy/relocate/com/aallam/openai/api\\E"
235+
}, {
236+
"pattern":"\\Qio/github/stream29/proxy/relocate/com/aallam/openai\\E"
237+
}, {
238+
"pattern":"\\Qio/github/stream29/proxy/relocate/com/aallam\\E"
239+
}, {
240+
"pattern":"\\Qio/github/stream29/proxy/relocate/com\\E"
241+
}, {
242+
"pattern":"\\Qio/github/stream29/proxy/relocate\\E"
231243
}, {
232244
"pattern":"\\Qio/github/stream29/proxy/server\\E"
233245
}, {
@@ -262,6 +274,10 @@
262274
"pattern":"\\Qio/ktor/client\\E"
263275
}, {
264276
"pattern":"\\Qio/ktor/events\\E"
277+
}, {
278+
"pattern":"\\Qio/ktor/http/cio/internals\\E"
279+
}, {
280+
"pattern":"\\Qio/ktor/http/cio\\E"
265281
}, {
266282
"pattern":"\\Qio/ktor/http/content\\E"
267283
}, {
@@ -276,6 +292,8 @@
276292
"pattern":"\\Qio/ktor/network/tls/platform\\E"
277293
}, {
278294
"pattern":"\\Qio/ktor/network/tls\\E"
295+
}, {
296+
"pattern":"\\Qio/ktor/network/util\\E"
279297
}, {
280298
"pattern":"\\Qio/ktor/network\\E"
281299
}, {
@@ -284,6 +302,8 @@
284302
"pattern":"\\Qio/ktor/serialization/kotlinx\\E"
285303
}, {
286304
"pattern":"\\Qio/ktor/serialization\\E"
305+
}, {
306+
"pattern":"\\Qio/ktor/server/application/debug\\E"
287307
}, {
288308
"pattern":"\\Qio/ktor/server/application/hooks\\E"
289309
}, {
@@ -328,6 +348,10 @@
328348
"pattern":"\\Qio/ktor/util/collections\\E"
329349
}, {
330350
"pattern":"\\Qio/ktor/util/date\\E"
351+
}, {
352+
"pattern":"\\Qio/ktor/util/debug/plugins\\E"
353+
}, {
354+
"pattern":"\\Qio/ktor/util/debug\\E"
331355
}, {
332356
"pattern":"\\Qio/ktor/util/internal\\E"
333357
}, {
@@ -340,6 +364,10 @@
340364
"pattern":"\\Qio/ktor/util\\E"
341365
}, {
342366
"pattern":"\\Qio/ktor/utils/io/charsets\\E"
367+
}, {
368+
"pattern":"\\Qio/ktor/utils/io/core\\E"
369+
}, {
370+
"pattern":"\\Qio/ktor/utils/io/pool\\E"
343371
}, {
344372
"pattern":"\\Qio/ktor/utils/io\\E"
345373
}, {
@@ -630,6 +658,8 @@
630658
"pattern":"\\Qkotlin/internal\\E"
631659
}, {
632660
"pattern":"\\Qkotlin/io\\E"
661+
}, {
662+
"pattern":"\\Qkotlin/jdk7\\E"
633663
}, {
634664
"pattern":"\\Qkotlin/jvm/functions\\E"
635665
}, {
@@ -770,6 +800,10 @@
770800
"pattern":"\\Qkotlin\\E"
771801
}, {
772802
"pattern":"\\Qkotlinx/coroutines/channels\\E"
803+
}, {
804+
"pattern":"\\Qkotlinx/coroutines/flow/internal\\E"
805+
}, {
806+
"pattern":"\\Qkotlinx/coroutines/flow\\E"
773807
}, {
774808
"pattern":"\\Qkotlinx/coroutines/internal\\E"
775809
}, {
@@ -784,6 +818,10 @@
784818
"pattern":"\\Qkotlinx/coroutines\\E"
785819
}, {
786820
"pattern":"\\Qkotlinx/io/files\\E"
821+
}, {
822+
"pattern":"\\Qkotlinx/io/internal\\E"
823+
}, {
824+
"pattern":"\\Qkotlinx/io/unsafe\\E"
787825
}, {
788826
"pattern":"\\Qkotlinx/io\\E"
789827
}, {
@@ -826,8 +864,16 @@
826864
"pattern":"\\Qokio\\E"
827865
}, {
828866
"pattern":"\\Qorg/fusesource/jansi/internal/native/Windows/x86_64/jansi.dll\\E"
867+
}, {
868+
"pattern":"\\Qorg/fusesource/jansi/internal\\E"
869+
}, {
870+
"pattern":"\\Qorg/fusesource/jansi/io\\E"
829871
}, {
830872
"pattern":"\\Qorg/fusesource/jansi/jansi.properties\\E"
873+
}, {
874+
"pattern":"\\Qorg/fusesource/jansi\\E"
875+
}, {
876+
"pattern":"\\Qorg/fusesource\\E"
831877
}, {
832878
"pattern":"\\Qorg/jcp/xml/dsig/internal/dom\\E"
833879
}, {
@@ -968,10 +1014,10 @@
9681014
"pattern":"\\Qsun/security/util\\E"
9691015
}, {
9701016
"pattern":"\\Qsun/security\\E"
971-
}, {
972-
"pattern":"\\Qsun/text/resources/cldr/ext\\E"
9731017
}, {
9741018
"pattern":"\\Qsun/text/resources/cldr\\E"
1019+
}, {
1020+
"pattern":"\\Qsun/text/resources/ext\\E"
9751021
}, {
9761022
"pattern":"\\Qsun/text/resources\\E"
9771023
}, {
@@ -1150,10 +1196,10 @@
11501196
"pattern":"java.base:\\Qsun/security/provider/certpath/ldap\\E"
11511197
}, {
11521198
"pattern":"java.base:\\Qsun/security/provider/certpath\\E"
1153-
}, {
1154-
"pattern":"java.base:\\Qsun/text/resources/cldr/ext\\E"
11551199
}, {
11561200
"pattern":"java.base:\\Qsun/text/resources/cldr\\E"
1201+
}, {
1202+
"pattern":"java.base:\\Qsun/text/resources/ext\\E"
11571203
}, {
11581204
"pattern":"java.base:\\Qsun/text/resources\\E"
11591205
}, {

0 commit comments

Comments
 (0)