streamlit-copilot-textarea
a drop-in replacement for the standard streamlit textarea, offering enhanced autocomplete features powered by AI.
Installation
pip install streamlit-copilot-textarea
Usage
from streamlit_copilot_textarea import st_copilot_textarea
value = st_copilot_textarea(
prompt_template="please complete the text: {input_text}",
api_url="http://localhost:8000/generate",
requests_per_minute=20,
max_tokens=10,
stop=["\n", "."],
)
st.write(f"Your text: {value}")
prompt_template: the prompt template to be sent to the api. It must contain{input_text}, which will be replaced by the user input.api_url: the url of the api to be used (see below for sever).requests_per_minute: the number of requests per minute to be made to the api.max_tokens: the maximum number of tokens to be generated.stop: the tokens where the generation should stop.
server.py: fastapi example
from fastapi import FastAPI
from pydantic import BaseModel
app = FastAPI()
class Payload(BaseModel):
prompt: str
# Add other fields that might be part of model_kwargs
temperature: Optional[float] = None
max_tokens: Optional[int] = None
@app.post("/generate")
async def generate(payload: Payload):
# here the prompt's {input_text} is already replaced with the user input.
prompt = payload.prompt
completion_text = request_chatgpt_here(prompt, payload.temperature, payload.max_tokens)
response = {"choices": [{"text": completion_text}]}
return response
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="0.0.0.0", port=8000)
test your copilot api
curl -X POST "http://localhost:8000/generate" -H "Content-Type: application/json" -d '{"prompt": "please complete the text: Human and AI", "temperature": 0.5, "max_tokens": 10}'
Buiding from source
Prerequisites
- nodejs >= 18.x
- yarn >= 1.22.x
- poetry >= 1.2.x
- python >= 3.8.x
Building
./build.sh
Publishing
poetry publish
Thanks
License
This project is licensed under the MIT License - see the LICENSE file for details
Metadata
Release files for streamlit-copilot-textarea 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| streamlit_copilot_textarea-1.0.2.tar.gz | 811.9 kB | Without provenance | Details for streamlit_copilot_textarea-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| streamlit_copilot_textarea-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for streamlit_copilot_textarea-1.0.2-py3-none-any.whl |
Total release size: 1.3 MB
Release files / streamlit_copilot_textarea-1.0.2.tar.gz
| Download URL | streamlit_copilot_textarea-1.0.2.tar.gz |
|---|---|
| Size | 811.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
51e85070cda8f1a9dd54c39b195d83d14e647cf40aad0f4dec32e917dec0fbf5
|
|
BLAKE2b-256 checksum How to use checksums |
88ec66ea5e82b01c1895fff6b63ab090d93a9de6bd87263bc9b69428f96398c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.16 Darwin/23.4.0
|
Release files / streamlit_copilot_textarea-1.0.2-py3-none-any.whl
| Download URL | streamlit_copilot_textarea-1.0.2-py3-none-any.whl |
|---|---|
| Size | 446.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3824c3f54054f4cc94f18d7b32865b7534a7c49f4f2d9ec156a19d6fcfd9de54
|
|
BLAKE2b-256 checksum How to use checksums |
6d42fbccdb8c03c370ef851801163096b2c4147f2bd4ac269fcabd161b3c96fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.9.16 Darwin/23.4.0
|
Security for streamlit-copilot-textarea 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.