{"id":16200224,"url":"https://github.com/mobarski/st_repl_connection","last_synced_at":"2026-04-29T01:34:05.904Z","repository":{"id":184046614,"uuid":"671223924","full_name":"mobarski/st_repl_connection","owner":"mobarski","description":"Connect Streamlit to local REPL applications","archived":false,"fork":false,"pushed_at":"2023-08-02T16:19:29.000Z","size":4619,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-07T17:49:57.493Z","etag":null,"topics":["pexpect","repl","streamlit"],"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/mobarski.png","metadata":{"files":{"readme":"README.md","changelog":null,"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-26T20:37:10.000Z","updated_at":"2023-07-28T14:39:20.000Z","dependencies_parsed_at":"2024-11-03T11:36:34.884Z","dependency_job_id":null,"html_url":"https://github.com/mobarski/st_repl_connection","commit_stats":null,"previous_names":["mobarski/st_repl_connection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mobarski/st_repl_connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobarski%2Fst_repl_connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobarski%2Fst_repl_connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobarski%2Fst_repl_connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobarski%2Fst_repl_connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mobarski","download_url":"https://codeload.github.com/mobarski/st_repl_connection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mobarski%2Fst_repl_connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32407164,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["pexpect","repl","streamlit"],"created_at":"2024-10-10T09:29:35.679Z","updated_at":"2026-04-29T01:34:05.885Z","avatar_url":"https://github.com/mobarski.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streamlit ReplConnection\n\nConnect to local REPL applications from your [Streamlit](https://streamlit.io/) app.\n\nFor example you can control [llama.cpp](https://github.com/ggerganov/llama.cpp) session from your app!\n\n\u003e Why connect in this way and not via wrapper like [llama-cpp-python](https://github.com/abetlen/llama-cpp-python)?\n\u003e\n\u003e - You don't have to wait for the wrapper update and can use the newest features.\n\u003e - You can run in on machines without a c/cpp compiler.\n\u003e - It's easier to deploy.\n\u003e\n\n![screenshot](static/screenshot1.png)\n\n\n\n## Installation\n\n```\npip install git+https://github.com/mobarski/st_repl_connection\n```\n\n\n\n## Quick demonstration\n\n```python\nimport streamlit as st\nfrom st_repl_connection import ReplConnection\n\nmodel = st.experimental_connection(\"llama_cpp_hermes\", type=ReplConnection)\nresp = model.query('Compare Linux and MacOS.')\nst.write(resp)\n```\n\n\n\n## Main methods\n\n\n\n#### query()\n\n`connection.query(text, ttl=None) -\u003e str`\n\n- `text` - text to send to the application\n- `ttl` - cache the response for `ttl` seconds, `None` -\u003e no caching\n\n\n\n#### reset()\n\n`connection.reset()`\n\nResets the connection by re-running the REPL application.\n\n\n\n## Connection parameters\n\n\n\n- `command` - command to execute to run the REPL application\n- `prompt` - prompt used by the REPL application (`'\u003e\u003e\u003e '` for python, `'\u003e '` for llama.cpp, etc)\n- `encoding` - text encoding used by the REPL application, default: `'utf8'`\n\n\n\nYou can read about connections in [this section](https://docs.streamlit.io/library/api-reference/connections/st.experimental_connection) of Streamlit documentation.\n\n\n\n## Usage examples\n\n\n\n##### simple_app.py\n\n```python\nimport streamlit as st\nfrom st_repl_connection import ReplConnection\n\nmodel = st.experimental_connection(\"llama_cpp_hermes\", type=ReplConnection)\nresp = model.query('Compare Linux and MacOS.')\nst.write(resp)\n```\n\n\n\n##### chat_app.py\n\n```python\nimport streamlit as st\nss = st.session_state\n\nfrom st_repl_connection import ReplConnection\nmodel = st.experimental_connection(\"llama_cpp_hermes\", type=ReplConnection)\n\nif 'history' not in ss:\n    ss.history = []\nfor msg in ss.history:\n    with st.chat_message(msg['role']):\n        st.markdown(msg['content'])\n    \nprompt = st.chat_input('Your message or /clear')\nif prompt == '/clear':\n    ss.history = []\n    st.experimental_rerun()\nelif prompt:\n    with st.chat_message('user'):\n        st.markdown(prompt)\n        ss.history.append({'role': 'user', 'content': prompt})\n    resp = model.query(prompt)\n    with st.chat_message('assistant'):\n        st.markdown(resp)\n        ss.history.append({'role': 'assistant', 'content': resp})\n```\n\n###### chat questions ideas\n\n```\n- What is your name?\n- What is your quest?\n- What is your favorite color?\n- What is the capital of Assyria?\n- What is the airspeed velocity of an unladen swallow?\n- Compare Linux and MacOS.\n- Show example of a markdown table.\n- Count frequency of words in a file using python.\n- Compare PbtA and FitD.\n```\n\n\n\n##### Usage without streamlit\n\n```python\nfrom st_repl_connection import ReplController\n\nwith ReplController('python3 -i', '\u003e\u003e\u003e ') as app:\n    print(app.send('6 * 7'))\n    print(app.send('128 + 2**7'))\n```\n\n\n\n## Configuration examples\n\nThe configuration is stored in Streamlit's [secrets.toml](https://docs.streamlit.io/library/advanced-features/secrets-management) file (~/.streamlit/secrets.toml on Linux).\n\nYou can find more information about managing connections in [this section](docs.streamlit.io/library/advanced-features/connecting-to-data#global-secrets-managing-multiple-apps-and-multiple-data-stores) of Streamlit documentation.\n\n\n\n##### llama.cpp running the Hermes model on a GPU\n\n```toml\n[connections.llama_cpp_hermes]\ncommand = \"/opt/llama.cpp/main -m /opt/models/ggml-Hermes-2-step2559-q4_K_M.bin -ins -ngl 100\"\nprompt = \"\u003e \"\n```\n\n\n\n##### python running the turtle module\n\n```toml\n[connections.repl_turtle]\ncommand = \"python3 -i -c 'from turtle import *; home()'\"\nprompt = \"\u003e\u003e\u003e \"\n```\n\n\n\n##### sqlite\n\n```toml\n[connections.repl_sqlite]\ncommand = \"sqlite3 -box -header\"\nprompt = \"sqlite\u003e \"\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobarski%2Fst_repl_connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobarski%2Fst_repl_connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobarski%2Fst_repl_connection/lists"}