Commit f8832720 authored by Rayyyyy's avatar Rayyyyy
Browse files

modify chat

parent e005d327
...@@ -20,7 +20,7 @@ def main( ...@@ -20,7 +20,7 @@ def main(
max_seq_len=max_seq_len, max_seq_len=max_seq_len,
max_batch_size=max_batch_size, max_batch_size=max_batch_size,
) )
dialogs: List[Dialog] = [[]] # Start with an empty dialog dialogs: List[Dialog] = [] # Start with an empty dialog
try: try:
# Continue util the user decides to stop # Continue util the user decides to stop
while True: while True:
...@@ -28,19 +28,21 @@ def main( ...@@ -28,19 +28,21 @@ def main(
# Allow the user to quit the dialogue # Allow the user to quit the dialogue
if user_input.lower() in ['stop', 'exit']: if user_input.lower() in ['stop', 'exit']:
break break
dialogs[0].append({"role": "user", "content": user_input}) dialogs.append({"role": "user", "content": user_input})
# Generate response based on the current dialog context # Generate response based on the current dialog context
results = generator.chat_completion( results = generator.chat_completion(
[dialogs], [dialogs],
max_gen_len=max_gen_len, max_gen_len=max_gen_len,
temperature=temperature, temperature=temperature,
top_p=top_p,)[0] top_p=top_p,
response = results['generation']['content'] )
response = results[0]['generation']['content']
print(f"Assistant: {response}\n") print(f"Assistant: {response}\n")
# Append the generated response to the dialog # Append the generated response to the dialog
dialogs[0].append({"role": "assistant", "content": response}) dialogs.append({"role": "assistant", "content": response})
except KeyboardInterrupt: except KeyboardInterrupt:
print("Exiting dialogue.") print("Exiting dialogue.")
if __name__ == "__main__": if __name__ == "__main__":
fire.Fire(main) fire.Fire(main)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment