{"id":15539596,"url":"https://github.com/maxmekiska/llmnet","last_synced_at":"2025-10-09T20:33:48.805Z","repository":{"id":181713180,"uuid":"665693701","full_name":"maxmekiska/llmnet","owner":"maxmekiska","description":"A library designed to harness diversity of thought by combining multiple LLMs.","archived":false,"fork":false,"pushed_at":"2024-02-01T00:54:43.000Z","size":762,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-28T11:28:26.889Z","etag":null,"topics":["consensus","diversity","llm","network","thought"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxmekiska.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-12T19:28:02.000Z","updated_at":"2024-03-23T13:57:34.000Z","dependencies_parsed_at":"2024-02-18T11:31:47.439Z","dependency_job_id":null,"html_url":"https://github.com/maxmekiska/llmnet","commit_stats":null,"previous_names":["maxmekiska/llmnet"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/maxmekiska/llmnet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmekiska%2Fllmnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmekiska%2Fllmnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmekiska%2Fllmnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmekiska%2Fllmnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxmekiska","download_url":"https://codeload.github.com/maxmekiska/llmnet/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxmekiska%2Fllmnet/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002000,"owners_count":26083258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"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":["consensus","diversity","llm","network","thought"],"created_at":"2024-10-02T12:10:50.200Z","updated_at":"2025-10-09T20:33:48.770Z","avatar_url":"https://github.com/maxmekiska.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `llmnet`\n\nllmnet is a library designed to facilitate collaborative work among LLMs on diverse tasks. Its primary goal is to encourage a diversity of thought across various LLM models.\n\nllmnet comprises two main components:\n\n1. LLM network workers\n2. Consensus worker\n\n\nThe LLM network workers can independently and concurrently process tasks, while the consensus worker can access the various solutions and generate a final output. It's important to note that the consensus worker is optional and doesn't necessarily need to be employed.\n\n## Example\n\n### Prerequisite\n\nllmnet currently supports LLM models from OpenAI and Google. The user can define the model to be used for the LLM workers, as well as the model to be used for the consensus worker.\n\nPlease make sure to set env variables called `OPENAI_API_KEY`, `GOOGLE_API_KEY` to your OpenAi and Google keys.\n\n### How to use llmnet?\n\n#### llm worker\n\nYou have currently three llm worker at your disposal:\n\n1. openaillmbot\n2. googlellmbot\n3. randomllmbot\n4. randomopenaillmbot\n5. randomgooglellmbot\n\n##### `openaillmbot`\n\nInterface with OpenAi models.\n\noptional parameters:\n\n```\nmodel         (str) = 'gpt-3.5-turbo'\nmax_tokens    (int) = 2024\ntemperature   (float) = 0.1\nn             (int) = 1\nstop          (Union[str, List[str]]) = None\n```\n\n##### `googlellmbot`\n\nInterface with Google models.\n\noptional parameters:\n\n```\nmodel               (str) = 'gemini-pro'\nmax_output_tokens   (int) = 2024\ntemperature         (float) = 0.1\ntop_p               (float) = None\ntop_k               (int) = None\ncandidate_count     (int) = 1\nstop_sequences      (str) = None\n```\n\n##### `randomllmbot`\n\nSelect randomly between all available llmworkers and parameter specified.\n\noptional parameters:\n\n```\nrandom_configuration  (Dict) = {}\n```\n\nexample dict:\n\n```\n{\n    \"\u003cworker1\u003e\":\n    {\n        \"\u003cparameter1\u003e\": [\u003cpossible_arguments\u003e],\n        \"\u003cparameter2\u003e\": [\u003cpossible_arguments\u003e],\n        ...\n    },\n    \"\u003cworker2\u003e\":\n    {\n        \"\u003cparameter1\u003e\": [\u003cpossible_arguments\u003e],\n        \"\u003cparameter2\u003e\": [\u003cpossible_arguments\u003e]\n        ...\n    }\n    ...\n}\n```\n\n##### `randomopenaillmbot`\n\nSelect randomly between all configurations possible for OpenAi based llms.\n\noptional parameters - if not provided, defaults to `openaillmbot` default values:\n\n```\nrandom_configuration  (Dict) = {}\n```\n\nexample dict:\n\n```\n{\n    \"\u003cparameter1\u003e\": [\u003cpossible_arguments\u003e],\n    \"\u003cparameter2\u003e\": [\u003cpossible_arguments\u003e],\n    ...\n}\n```\n\n\n##### `randomgooglellmbot`\n\nSelect randomly between all configurations possible for Google based llms.\n\noptional parameters - if not provided, defaults to `googlellmbot` default values:\n\n```\nrandom_configuration  (Dict) = {}\n```\n\nexample dict:\n\n```\n{\n    \"\u003cparameter1\u003e\": [\u003cpossible_arguments],\n    \"\u003cparameter2\u003e\": [\u003cpossible_arguments],\n    ...\n}\n```\n#### `create_network`\n\n- creates llmworker network\n- expects:\n  - instruct: List[Dict[str, str]]\n    - structure: `[{\"objective\": xxx, \"context\": ooo}..]`, the context key is is optional\n  - worker: select any worker from the above\n  - max_concurrent_worker: how many API calls are allowed in parallel\n  - kwargs: any configuration for the worker selected\n  - access results via getter methods:\n    - get_worker_answers: collection of answers combined in one string\n    - get_worker_answers_messages: collection of answers with metadata\n\n#### `apply_consensus`\n\n- creates consensus worker\n- expects:\n  - worker: select any worker from the above\n  - kwargs: any configuration for the worker selected\n  - set_prompt: prompt to build consensus\n    - access results via getter methods:\n      - get_worker_consensus: consensus result as string\n      - get_worker_consensus_messages: consensus result with metadata\n\n#### Simple independent tasks - no consensus\n\n```python\nfrom llmnet import LlmNetwork\n\n\ninstructions = []\n\n\ninstructions =\n    [\n    {\"objective\": \"how many countries are there?\"},\n    {\"objective\": \"what is AGI\"},\n    {\"objective\": \"What is the purpose of biological life?\"}\n    ]\n\nnet = LlmNetwork()\n\nnet.create_network(\n    instruct=instructions,\n    worker=\"randomllmbot\",\n    max_concurrent_worker=2, # how many API calls are allowed in parallel\n    random_configuration={\n        \"googlellmbot\": {\"model\": [\"gemini-pro\"], \"temperature\": [0.12, 0.11]},\n        \"openaillmbot\": {\n            \"model\": [\"gpt-3.5-turbo\", \"gpt-4\"],\n            \"temperature\": [0.11, 0.45, 1],\n        },\n    },\n)\n\n# collection of answers as a string\nnet.get_worker_answers\n\n# collection of answers with metadata\nnet.get_worker_answer_messages\n```\n\n#### One task with same objective split between multiple workers - consensus\n\n```python\nfrom llmnet import LlmNetwork\n\n\ninstructions = []\n\n\ninstructions =\n    [\n    {\"objective\": \"What is empiricism?\", \"context\": \"Text Part One\"},\n    {\"objective\": \"What is empiricism?\", \"context\": \"Text Part Two\"},\n    {\"objective\": \"What is empiricism?\", \"context\": \"Text Part Three\"}\n    ]\n\nnet = LlmNetwork()\n\nnet.create_network(\n    instruct=instructions,\n    worker=\"randomllmbot\",\n    max_concurrent_worker=2, # how many API calls are allowed in parallel\n    random_configuration={\n        \"googlellmbot\": {\"model\": [\"gemini-pro\"], \"temperature\": [0.12, 0.11]},\n        \"openaillmbot\": {\n            \"model\": [\"gpt-3.5-turbo\"],\n            \"temperature\": [0.11, 0.45, 1],\n        },\n    },\n)\n\n# collection of answers as a string\nnet.get_worker_answers\n\n# collection of answers with metadata\nnet.get_worker_answer_messages\n\n# apply consensus\nnet.apply_consensus(\n    worker=\"openaillmbot\",\n    model=\"gpt-3.5-turbo\",\n    temperature=0.7,\n    set_prompt=f\"Answer this objective: What is empiricism? with the following text in just one sentences: {net.get_worker_answers}\",\n)\n\n# get final consensus answer as a string\nnet.get_worker_consensus\n\n# get answer with metadata\nnet.get_worker_consensus_messages\n```\n\n#### Other example use cases\n\n- independent objectives, choose best solution via consensus\n- mixed objectives with and without context, with or without consensus\n- etc.\n\n## Appendix\n\nMap reduce by LangChain: [LangChain MapReduce Documentation](https://python.langchain.com/docs/modules/chains/document/map_reduce)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxmekiska%2Fllmnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxmekiska%2Fllmnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxmekiska%2Fllmnet/lists"}