{"id":49325532,"url":"https://github.com/wangmuy/llmchain","last_synced_at":"2026-05-29T21:00:53.575Z","repository":{"id":167508425,"uuid":"634570916","full_name":"wangmuy/llmchain","owner":"wangmuy","description":"LangChain for android/Java/JVM/Kotlin Multiplatform, using OpenAI chatGPT compatible APIs","archived":false,"fork":false,"pushed_at":"2023-10-03T00:00:57.000Z","size":303,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"multiplatform","last_synced_at":"2023-10-03T09:33:01.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wangmuy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-04-30T15:09:19.000Z","updated_at":"2023-10-03T09:33:01.045Z","dependencies_parsed_at":"2023-10-02T06:30:42.684Z","dependency_job_id":null,"html_url":"https://github.com/wangmuy/llmchain","commit_stats":null,"previous_names":["wangmuy/llmchain"],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/wangmuy/llmchain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangmuy%2Fllmchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangmuy%2Fllmchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangmuy%2Fllmchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangmuy%2Fllmchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wangmuy","download_url":"https://codeload.github.com/wangmuy/llmchain/tar.gz/refs/heads/multiplatform","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangmuy%2Fllmchain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33670211,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-29T02:00:06.066Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-04-26T20:00:31.588Z","updated_at":"2026-05-29T21:00:53.569Z","avatar_url":"https://github.com/wangmuy.png","language":"Kotlin","funding_links":[],"categories":["人工智能"],"sub_categories":["LLM框架"],"readme":"# LLMChain\nThis is an experimental port of [langchain( currently v0.0.139 )](https://github.com/hwchase17/langchain/tree/v0.0.139) to android/JVM/Kotlin Multiplatform.\nPlease note that this project is currently in the proof-of-concept stage, and is subject to change.\n\n## Maven repository\nOnly the SNAPSHOT version is published.\n\nAdd to repositories\n```gradle\nrepositories {\n    mavenCentral()\n    maven { url \"https://s01.oss.sonatype.org/content/repositories/snapshots/\" }\n}\n```\n\nAdd to dependencies\n* Android/JVM developers are advised to use the android branch README dependency directions.\n* For Kotlin Multiplatform developers, try to add the following\n```gradle\ndependencies {\n    implementation(\"io.github.wangmuy.llmchain.kmp:core:0.0.1-SNAPSHOT\") { changing=true }\n    implementation(\"io.github.wangmuy.llmchain.kmp:serviceprovider-openai:0.0.1-SNAPSHOT\") { changing=true }\n}\n```\nBe sure to checkout the support matrix.\n\n### Multiplatform support matrix\n\n| package                | platform | isCompiled | isTested |\n|------------------------|----------|------------|----------|\n| core                   | jvm      | true       | true     |\n| core                   | ios      | false      | false    |\n| core                   | native   | true       | true     |\n| core                   | js       | true       | true     |\n| core                   | wasm     | true       | false    |\n| serviceprovider-openai | jvm      | true       | true     |\n| serviceprovider-openai | ios      | false      | false    |\n| serviceprovider-openai | native   | true       | true     |\n| serviceprovider-openai | js       | true       | false    |\n| serviceprovider-openai | wasm     | false      | false    |\n\n## Quickstart\nHere's the almost one-to-one translation of  [langchain Quickstart Guide](https://python.langchain.com/docs/get_started/quickstart)\n in [Quickstart.kt](https://github.com/wangmuy/llmchain/blob/main/core/src/test/kotlin/com/wangmuy/llmchain/Quickstart.kt), including all the modules/components.\n\n### LLMs\n```kotlin\nval llm = OpenAIChat(APIKEY, proxy = PROXY)\nllm.invocationParams[OpenAIChat.REQ_TEMPERATURE] = 0.9\nval text = \"What would be a good company name for a company that makes colorful socks?\"\nval output = llm.invoke(text, null)\nprintln(\"output=\\n$output\")\n```\n\n### Prompt templates\n```kotlin\nval prompt = PromptTemplate(\n    inputVariables = listOf(\"product\"),\n    template = \"What is a good name for a company that makes {product}?\")\nval formatted = prompt.format(mapOf(\"product\" to \"colorful socks\"))\nassertEquals(\"What is a good name for a company that makes colorful socks?\", formatted)\n```\n\n### Chains\n```kotlin\nval llm = OpenAIChat(APIKEY)\nllm.invocationParams[OpenAIChat.REQ_TEMPERATURE] = 0.9\nval prompt = PromptTemplate(\n    inputVariables = listOf(\"product\"),\n    template = \"What is a good name for a company that makes {product}?\")\nval chain = LLMChain(llm = llm, prompt = prompt)\nval output = chain.run(mapOf(\"product\" to \"colorful socks\"))\nprintln(\"output=\\n$output\")\n```\n\n### Agents\n```kotlin\nval llm = OpenAIChat(APIKEY)\nllm.invocationParams[OpenAIChat.REQ_TEMPERATURE] = 0.0\nval fakeSerpApiTool = Tool(\n    name = \"Search\",\n    description = \"A search engine. Useful for when you need to answer questions about current events. Input should be a search query.\",\n    func = {_, _ -\u003e \"San Francisco Temperature Yesterday. Maximum temperature yesterday: 57 °F (at 1:56 pm) Minimum temperature yesterday: 49 °F (at 1:56 am)\"}\n)\nval llmMathTool = LLMMathChain.asTool(llm)\nval agentExecutor = Factory.initializeAgent(listOf(fakeSerpApiTool, llmMathTool), llm,\n    Factory.AGENT_TYPE_ZERO_SHOT_REACT_DESCRIPTION)\nagentExecutor.maxIterations = 4\nval output = agentExecutor.run(mapOf(\"input\" to \"What was the high temperature in SF yesterday in Fahrenheit? What is that number raised to the .023 power?\"))\nprintln(\"output=\\n$output\")\n```\n\n### Memory\n```kotlin\nval logCallbackHandler = object: DefaultCallbackHandler() {\n    override fun onText(text: String, verbose: Boolean) {\n        println(text)\n    }\n}\nval callbackManager = CallbackManager(mutableListOf(logCallbackHandler))\nval llm  = OpenAIChat(APIKEY).apply {\n    invocationParams[OpenAIChat.REQ_MAX_TOKENS] = 50\n}\nllm.callbackManager = callbackManager\nval conversation = ConversationChain(llm, verbose = true, callbackManager = callbackManager)\nvar output: Map\u003cString, Any\u003e = emptyMap()\nvar outputStr: String = \"\"\noutput = conversation.invoke(mapOf(\"input\" to \"Hi there!\"))\noutputStr = output[conversation.outputKey]!!.toString()\nprintln(\"output=\\n$outputStr\")\noutput = conversation.invoke(mapOf(\"input\" to \"I'm doing well! Just having a conversation with an AI.\"))\n```\n\n## implementations\n- Schema\n  - [x] nearly all basic schema interfaces\n- LLM\n  - [x] BaseLLM\n  - [x] LLM\n- Prompt template\n  - [x] BasePromptTemplate\n  - [x] StringPromptTemplate\n  - [x] StringPromptValue\n  - [x] PromptTemplate\n- Chain\n  - [x] Chain\n  - [x] LLMChain\n  - [ ] LLMMathChain: currently use LLM, not the actual calculator\n  - [x] ConversationChain\n  - [x] RouterChain/MultiRouteChain/LLMRouterChain/MultiPromptChain Note: Only available in jvm/native due to limited implementation of `RegexOption.DOT_MATCHES_ALL`\n  - [x] SequentialChain/SimpleSequentialChain\n- Agent\n  - [x] Agent\n  - [x] AgentExecutor\n  - [x] ZeroShotAgent\n- Tools\n  - [x] BaseTool\n  - [x] Tool\n  - [x] InvalidTool\n- Memory\n  - [x] SimpleMemory\n  - [x] ChatMemory\n- DocStore\n  - [x] DocStore\n  - [x] InMemoryDocStore\n- VectorStore\n  - [x] VectorStore\n  - [x] SimpleVectorStore\n  - [x] VectorStoreRetriever\n- Embedding\n  - [x] Embeddings\n\n\n- LLM service provider\n  - [x] OpenAI \n    - [x] OpenAIChat\n    - [x] OpenAIEmbedding\n    - [x] Function Calling\n\n## License\n```text\nCopyright 2023 wangmuy\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangmuy%2Fllmchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangmuy%2Fllmchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangmuy%2Fllmchain/lists"}