forked from daveshap/KB_microservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_kb_service.py
55 lines (39 loc) · 1.4 KB
/
test_kb_service.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import requests
import json
from pprint import pprint as pp
def test_create_endpoint():
text = input("Enter the text for the new KB article: ")
payload = {"input": text}
response = requests.post("http://localhost:999/create", json=payload)
print('\n\n\n', response.json())
def test_search_endpoint():
query = input("Enter the search query: ")
payload = {"query": query}
response = requests.post("http://localhost:999/search", json=payload)
print('\n\n\n')
pp(response.json())
def test_update_endpoint():
title = input("Enter the title of the KB article to update: ")
text = input("Enter the new text for the KB article: ")
payload = {"title": title, "input": text}
response = requests.post("http://localhost:999/update", json=payload)
print('\n\n\n', response.json())
def main():
while True:
print("\n\n\n1. Create KB article")
print("2. Search KB articles")
print("3. Update KB article")
print("4. Exit")
choice = input("\n\nEnter your choice: ")
if choice == '1':
test_create_endpoint()
elif choice == '2':
test_search_endpoint()
elif choice == '3':
test_update_endpoint()
elif choice == '4':
break
else:
print("\n\n\nInvalid choice. Please enter a number between 1 and 4.")
if __name__ == "__main__":
main()