From f43107aa764acb59dbbaad5d5ac6fb53f3990057 Mon Sep 17 00:00:00 2001 From: Raju Komati Date: Wed, 26 Apr 2023 23:50:18 +0530 Subject: refactored you code added error handling and updated regex for parsing response --- testing/you_test.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'testing/you_test.py') diff --git a/testing/you_test.py b/testing/you_test.py index 9c69cf34..6ba12f57 100644 --- a/testing/you_test.py +++ b/testing/you_test.py @@ -1,10 +1,7 @@ import you # simple request with links and details -response = you.Completion.create( - prompt = "hello world", - detailed = True, - includelinks = True) +response = you.Completion.create(prompt="hello world", detailed=True, include_links=True) print(response) @@ -16,17 +13,15 @@ print(response) # } # } -#chatbot +# chatbot chat = [] while True: prompt = input("You: ") - - response = you.Completion.create( - prompt = prompt, - chat = chat) - + + response = you.Completion.create(prompt=prompt, chat=chat) + print("Bot:", response["response"]) - - chat.append({"question": prompt, "answer": response["response"]}) \ No newline at end of file + + chat.append({"question": prompt, "answer": response["response"]}) -- cgit v1.2.3