mirror of
https://github.com/danswer-ai/danswer.git
synced 2025-09-19 20:24:32 +02:00
Prompt Tuning and minor QOA changes (#2)
This commit is contained in:
@@ -109,6 +109,6 @@ if __name__ == "__main__":
|
||||
if args.rebuild_index:
|
||||
recreate_collection(args.qdrant_collection)
|
||||
|
||||
#load_slack_batch(args.slack_export_dir, args.qdrant_collection)
|
||||
# load_slack_batch(args.slack_export_dir, args.qdrant_collection)
|
||||
load_web_batch(args.website_url, args.qdrant_collection)
|
||||
#load_google_drive_batch(args.qdrant_collection)
|
||||
# load_google_drive_batch(args.qdrant_collection)
|
||||
|
@@ -9,50 +9,55 @@ from danswer.configs.constants import SOURCE_TYPE
|
||||
if __name__ == "__main__":
|
||||
previous_query = None
|
||||
while True:
|
||||
keyword_search = False
|
||||
query = input(
|
||||
"\n\nAsk any question:\n - prefix with -k for keyword search\n - input an empty string to "
|
||||
"rerun last query\n\t"
|
||||
)
|
||||
try:
|
||||
keyword_search = False
|
||||
query = input(
|
||||
"\n\nAsk any question:\n - prefix with -k for keyword search\n - input an empty string to "
|
||||
"rerun last query\n\t"
|
||||
)
|
||||
|
||||
if query.lower() in ["q", "quit", "exit", "exit()"]:
|
||||
break
|
||||
if query.lower() in ["q", "quit", "exit", "exit()"]:
|
||||
break
|
||||
|
||||
if query:
|
||||
previous_query = query
|
||||
else:
|
||||
if not previous_query:
|
||||
print("No previous query")
|
||||
continue
|
||||
print(f"Re-executing previous question:\n\t{previous_query}")
|
||||
query = previous_query
|
||||
|
||||
endpoint = f"http://127.0.0.1:{APP_PORT}/direct-qa"
|
||||
if query.startswith("-k "):
|
||||
keyword_search = True
|
||||
query = query[2:]
|
||||
endpoint = f"http://127.0.0.1:{APP_PORT}/keyword-search"
|
||||
|
||||
response = requests.post(
|
||||
endpoint, json={"query": query, "collection": QDRANT_DEFAULT_COLLECTION}
|
||||
)
|
||||
contents = json.loads(response.content)
|
||||
if keyword_search:
|
||||
if contents["results"]:
|
||||
for link in contents["results"]:
|
||||
print(link)
|
||||
if query:
|
||||
previous_query = query
|
||||
else:
|
||||
print("No matches found")
|
||||
else:
|
||||
answer = contents.get("answer")
|
||||
if answer:
|
||||
print("Answer: " + answer)
|
||||
if not previous_query:
|
||||
print("No previous query")
|
||||
continue
|
||||
print(f"Re-executing previous question:\n\t{previous_query}")
|
||||
query = previous_query
|
||||
|
||||
endpoint = f"http://127.0.0.1:{APP_PORT}/direct-qa"
|
||||
if query.startswith("-k "):
|
||||
keyword_search = True
|
||||
query = query[2:]
|
||||
endpoint = f"http://127.0.0.1:{APP_PORT}/keyword-search"
|
||||
|
||||
response = requests.post(
|
||||
endpoint, json={"query": query, "collection": QDRANT_DEFAULT_COLLECTION}
|
||||
)
|
||||
contents = json.loads(response.content)
|
||||
if keyword_search:
|
||||
if contents["results"]:
|
||||
for link in contents["results"]:
|
||||
print(link)
|
||||
else:
|
||||
print("No matches found")
|
||||
else:
|
||||
print("Answer: ?")
|
||||
if contents.get("quotes"):
|
||||
for ind, (quote, quote_info) in enumerate(contents["quotes"].items()):
|
||||
print(f"Quote {str(ind)}:\n{quote}")
|
||||
print(f"Link: {quote_info['link']}")
|
||||
print(f"Source: {quote_info[SOURCE_TYPE]}")
|
||||
else:
|
||||
print("No quotes found")
|
||||
answer = contents.get("answer")
|
||||
if answer:
|
||||
print("Answer: " + answer)
|
||||
else:
|
||||
print("Answer: ?")
|
||||
if contents.get("quotes"):
|
||||
for ind, (quote, quote_info) in enumerate(
|
||||
contents["quotes"].items()
|
||||
):
|
||||
print(f"Quote {str(ind + 1)}:\n{quote}")
|
||||
print(f"Link: {quote_info['link']}")
|
||||
print(f"Source: {quote_info[SOURCE_TYPE]}")
|
||||
else:
|
||||
print("No quotes found")
|
||||
except Exception as e:
|
||||
print(f"Failed due to {e}, retrying")
|
||||
|
Reference in New Issue
Block a user