Skip to main content

Streamlit component that allows you to build your own simple github copilot

Project description

streamlit-custom-component

Streamlit component that allows you to build your own simple github copilot

Installation instructions

pip install streamlit-monaco-copilot

Usage instructions

type some code in the text area, and use shift + enter to run the component

import streamlit as st
from streamlit_monaco_copilot import st_monaco_copilot


from uuid import uuid4

value = st_monaco_copilot(
    "foo", 
    language='python',
    initial_code='print("hello world")',
    suggestion=st.session_state.get('suggestion', ''), 
    key='fixed'  # component need a key! or it will not be destoryed by streamlit rerun when suggestion changed!
)


value


if value and value.get('uuid'):
    new_uuid = value['uuid']
else:
    new_uuid = ''

if value and new_uuid and new_uuid != st.session_state.get('uuid'):
    # maybe use openai or deepseek api to get suggestion
    st.session_state['suggestion'] = 'i have suggestion about this code: `' + value.get('beforeCursor', '') + '`'
    st.session_state['uuid'] = new_uuid
    import time 
    time.sleep(1)  # i don't know why, but without this, the fontend component will not work
    st.rerun()

todo

  • remove toolkit near inline suggestion code
  • add selectedText
  • add cursor position

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

streamlit_monaco_copilot-0.0.2.dev2.tar.gz (429.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

streamlit_monaco_copilot-0.0.2.dev2-py3-none-any.whl (432.5 kB view details)

Uploaded Python 3

File details

Details for the file streamlit_monaco_copilot-0.0.2.dev2.tar.gz.

File metadata

File hashes

Hashes for streamlit_monaco_copilot-0.0.2.dev2.tar.gz
Algorithm Hash digest
SHA256 b66b577a16e413adcfdd9943836eaecd8131299a3ad817ac35b029cd02c0130e
MD5 e1fcb539515d5b5986a54884272732a1
BLAKE2b-256 448c5b114455c1c8f3d5e347f8a1b887548a35ef5e664268cebe750e6c0dc524

See more details on using hashes here.

File details

Details for the file streamlit_monaco_copilot-0.0.2.dev2-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_monaco_copilot-0.0.2.dev2-py3-none-any.whl
Algorithm Hash digest
SHA256 f636a09cbef35623d2c0feaa90f5305582fba5d8fc1bf98df8ab18b33dd418ad
MD5 507187db57d3834eccd443793052ad48
BLAKE2b-256 40f4809e83527f3c81304007741327980bb86d250097fc183ef976e89f7103c4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page