Skip to content

Commit

Permalink
add streaming test
Browse files Browse the repository at this point in the history
  • Loading branch information
filip-michalsky committed Jul 6, 2023
1 parent 1cf9009 commit 4df1426
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion tests/test_salesgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,37 @@ def test_valid_inference(self, load_env):


def test_valid_inference_stream(self, load_env):
pass
"""Test that the agent will start and generate the first utterance when streaming."""

llm = ChatOpenAI(temperature=0.9)
model_name = 'gpt-3.5-turbo'

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()
sales_agent.determine_conversation_stage() # optional for demonstration, built into the prompt

# agent output sample
stream_generator = sales_agent.step(return_streaming_generator=True, model_name=model_name)
agent_output=''
for chunk in stream_generator:
token = chunk["choices"][0]["delta"].get("content", "")
agent_output += token

assert agent_output is not None, "Agent output cannot be None."
assert isinstance(agent_output, str), "Agent output needs to be of type str"
assert len(agent_output) > 0, "Length of output needs to be greater than 0."

0 comments on commit 4df1426

Please sign in to comment.