Comments (3)
import os from langchain import PromptTemplate, OpenAI, LLMChain import chainlit as cl
#os.environ["OPENAI_API_KEY"] = "YOUR_OPEN_AI_API_KEY"
template = """Question: {question}
Answer: Let's think step by step."""
llm=OpenAI(temperature=0,streaming=True)
@cl.langchain_factory def factory():
prompt = PromptTemplate(template=template, input_variables=["question"]) llm_chain = LLMChain(prompt=prompt, llm=llm , verbose=True) return llm_chain
Since you are using an LLMChain
the streamed content will be inside the working box that appears. If you ask it to tell you a 200 word story and then expand the box. You will see that the content within is streaming.
Please confirm if this is working for you so we can close this issue.
If instead you want to stream the content directly. Below is a simple example of how to feed a message directly back to the UI using streaming.
import chainlit as cl
from langchain.chat_models import ChatOpenAI
from langchain.schema import HumanMessage
llm = ChatOpenAI(streaming=True)
@cl.on_message
def main(message: str):
cl.Message(content="") # Need to set the Message content to be blank before trigging the llm.
llm([HumanMessage(content=message)])
The above work around using cl.Message(content="")
is needed and will be fixed in a future release. It is required as of version 0.2.109
from chainlit.
At the moment the intermediate steps should be streamed and not the final response. Is that the case or even the intermediate steps are not being streamed? You can see #7 (comment) for context
from chainlit.
thanks
from chainlit.
Related Issues (20)
- Azure OpenAI support HOT 3
- chainlit use graphsignal err HOT 1
- -w argument in the chainlit run command doesn't work yet HOT 7
- Ability to add additional UI component types (e. g. new tab, custom code)
- AttributeError: module 'select' has no attribute 'epoll'. HOT 2
- "Waiting for thread pool to idle before working"? HOT 1
- Cannot run on macOS HOT 2
- Really bad memory leak HOT 3
- Error: Invalid value: File does not exist: target.py HOT 3
- Why does the window that pops up locally after I specify the ip and port not display any content? HOT 21
- Feature request: Bind Actions / Ask Users to the TextArea input menu HOT 2
- Having the same issue here. Running on a linux server, no error message, just a blank page. Specifying the host and port did not help in any way. HOT 7
- LAN SSL requirement HOT 2
- It consumes a significant amount of computer resources. HOT 12
- [Bug] Getting spammed with SSL Handshake Error when ru HOT 7
- work without any api key HOT 2
- Setting up the chainlit environment locally HOT 1
- After running the chainlit run app.py getting the error "Could not reach the server" HOT 3
- Deploy in PythonAnywhere HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chainlit.