-
Notifications
You must be signed in to change notification settings - Fork 460
/
streaming_generator_example.py
36 lines (28 loc) · 1.14 KB
/
streaming_generator_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from dotenv import load_dotenv
from langchain_community.chat_models import ChatLiteLLM
from salesgpt.agents import SalesGPT
load_dotenv()
llm = ChatLiteLLM(temperature=0.9, model_name="gpt-3.5-turbo-0613")
sales_agent = SalesGPT.from_llm(
llm,
verbose=False,
salesperson_name="Ted Lasso",
salesperson_role="Sales Representative",
company_name="Sleep Haven",
company_business="""Sleep Haven
is a premium mattress company that provides
customers with the most comfortable and
supportive sleeping experience possible.
We offer a range of high-quality mattresses,
pillows, and bedding accessories
that are designed to meet the unique
needs of our customers.""",
)
sales_agent.seed_agent()
# get generator of the LLM output
generator = sales_agent.step(stream=True)
# operate on streaming LLM output in near-real time
# for instance, do something after each full sentence is generated
for chunk in generator:
print(chunk)