-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional test for multi-turn flows (#13).
- Loading branch information
Showing
1 changed file
with
80 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
from nemoguardrails import RailsConfig | ||
from tests.utils import TestChat | ||
|
||
config = RailsConfig.from_content( | ||
""" | ||
define user ask general question | ||
"What is the capital of France?" | ||
"Who invented the game of chess?" | ||
define user ask capabilities | ||
"What can you do?" | ||
"Tell me what you can do" | ||
define user bey | ||
"bey" | ||
define flow | ||
user ask general question | ||
bot respond to general question | ||
define flow | ||
user ask capabilities | ||
bot inform capabilities | ||
define flow | ||
user ask general question | ||
bot respond to general question | ||
user ask general question | ||
bot respond to general question | ||
user ask general question | ||
bot respond to general question | ||
user bey | ||
bot respond bey back | ||
define bot respond bey back | ||
"Bey back!" | ||
define bot inform capabilities | ||
"I am an AI assistant built to showcase Security features of NeMo Guardrails!" | ||
""" | ||
) | ||
|
||
|
||
def test_1(): | ||
chat = TestChat( | ||
config, | ||
llm_completions=[ | ||
" ask general question", | ||
' "The capital of France is Paris."', | ||
" ask general question", | ||
' "The capital of Germany is Berlin."', | ||
" ask general question", | ||
' "The capital of Romania is Bucharest."', | ||
" bey", | ||
], | ||
) | ||
|
||
chat >> "What is the capital of France?" | ||
chat << "The capital of France is Paris." | ||
chat >> "and Germany?" | ||
chat << "The capital of Germany is Berlin." | ||
chat >> "and Romania?" | ||
chat << "The capital of Romania is Bucharest." | ||
chat >> "bey" | ||
chat << "Bey back!" |