
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
ChatStream is a chat toolkit for pre-trained large language models.
It can be embedded in FastAPI/Starlette based web applications/web APIs to perform sequential sentence generation with pre-trained language models under load control.
pip install chatstream
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu117
pip install transformers
pip install "uvicorn[standard]" gunicorn
Implement a streaming chat server for pre-trained models.
import torch
from fastapi import FastAPI, Request
from fastsession import FastSessionMiddleware, MemoryStore
from transformers import AutoTokenizer, AutoModelForCausalLM
from chatstream import ChatStream, ChatPromptTogetherRedPajamaINCITEChat as ChatPrompt
model_path = "togethercomputer/RedPajama-INCITE-Chat-3B-v1"
device = "cuda" # "cuda" / "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16)
model.to(device)
chat_stream = ChatStream(
num_of_concurrent_executions=2, # max_concurrent_executions for sentence generation
max_queue_size=5, # size of queue
model=model,
tokenizer=tokenizer,
device=device,
chat_prompt_clazz=ChatPrompt,
)
app = FastAPI()
# Specify session middleware to keep per-user ChatPrompt in the HTTP session
app.add_middleware(FastSessionMiddleware,
secret_key="your-session-secret-key",
store=MemoryStore(),
http_only=True,
secure=False,
)
@app.post("/chat_stream")
async def stream_api(request: Request):
# Just pass a FastAPI Request object to `handle_chat_stream_request` to automatically queue and control concurrency
response = await chat_stream.handle_chat_stream_request(request)
return response
@app.on_event("startup")
async def startup():
# start the queueing system by doing `start_queue_worker` at the same time the web server starts up
await chat_stream.start_queue_worker()
Implementation of Web API Endpoints
Queueing System and Concurrency Limit
Start the Web server (ASGI server)
Console chat implementation
Configuration during development
Advanced Settings
@software{chatstream,
title = {{ChatStream: A streaming chat toolkit for pre-trained large language models(LLM)}},
author = {Qualiteg Inc.(https://qualiteg.com) },
url = {https://github.com/qualiteg/ChatStream}
month = {5},
year = {2023},
version = {0.15},
}
FAQs
A streaming chat toolkit for pre-trained large language models(LLM)
We found that chatstream demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.