Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying Nomic Visualizations #72

Merged
merged 65 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
dbdd24a
new PR
star-nox Aug 29, 2023
fb1e0ea
added onResponseCompletion endpoint
star-nox Aug 30, 2023
4ee29ff
nomic log test push
star-nox Sep 5, 2023
5f39b3a
nomic log test push 2
star-nox Sep 5, 2023
1d40910
nomic changed to POST
star-nox Sep 5, 2023
82bf143
nomic changed back to GET
star-nox Sep 5, 2023
62b5b1b
nomic changed to POST
star-nox Sep 5, 2023
39d95f9
nomic moved print statements
star-nox Sep 5, 2023
36df49f
adding proper variables to /web-scrape endpoint
KastanDay Sep 5, 2023
e71c845
merging with main line
KastanDay Sep 5, 2023
a7b2072
Merge branch 'main' into nomic-viz
KastanDay Sep 5, 2023
b447c13
fix formatting in code formatting action (use double quotes)
KastanDay Sep 5, 2023
dc262bb
added prints for test
star-nox Sep 6, 2023
f1a4bf5
Merge branch 'nomic-viz' of https://github.com/UIUC-Chatbot/ai-ta-bac…
star-nox Sep 6, 2023
c1dafa4
added prints for test
star-nox Sep 6, 2023
772cd0b
added print for response body
star-nox Sep 6, 2023
c5c2bf8
modified logging function WIP
star-nox Sep 6, 2023
0686045
modified logging function WIP
star-nox Sep 6, 2023
a051bf1
modified logging function WIP
star-nox Sep 6, 2023
9294231
added print for response body
star-nox Sep 7, 2023
b56af3b
added print for response json
star-nox Sep 7, 2023
6ae4459
added print statements
star-nox Sep 7, 2023
1f57caf
added print statements
star-nox Sep 7, 2023
e0fa489
added print statements
star-nox Sep 7, 2023
e0e94f0
added print statements
star-nox Sep 7, 2023
6485cbe
iterating over response
star-nox Sep 7, 2023
85828f5
extracting relevant data
star-nox Sep 7, 2023
2e827b0
extracting relevant data
star-nox Sep 7, 2023
315ea1d
printing response data
star-nox Sep 7, 2023
e47b5a5
printing response data type
star-nox Sep 7, 2023
683afb2
iterating over response
star-nox Sep 7, 2023
b17876c
extracting messages
star-nox Sep 7, 2023
6d21c8f
extracting messages
star-nox Sep 7, 2023
f230d0c
added function for logging single-turn conversation
star-nox Sep 9, 2023
9d03c0b
completed workflow for multi-turn and map creation
star-nox Sep 11, 2023
c223990
changed method to POST
star-nox Sep 11, 2023
a53a544
added print statements on endpoint
star-nox Sep 11, 2023
be3d581
added get_json()
star-nox Sep 11, 2023
61068f8
added get_json()
star-nox Sep 11, 2023
dc28ca9
investigate data
star-nox Sep 11, 2023
f60e876
investigate data
star-nox Sep 11, 2023
b8cc471
removed jsonify(response)
star-nox Sep 11, 2023
7b046d6
added print statements in create_map()
star-nox Sep 11, 2023
1f67a10
added print statements in create_map()
star-nox Sep 11, 2023
2ca6d79
added print statements in create_map()
star-nox Sep 11, 2023
eea8bd3
Merge branch 'main' into nomic-viz
KastanDay Sep 11, 2023
530379d
added more print statements in create_map()
star-nox Sep 11, 2023
aeb6151
added emoji to metadata
star-nox Sep 11, 2023
7cc4077
handled emoji error
star-nox Sep 11, 2023
4f38670
added missing emoji
Sep 12, 2023
0e1f6af
replace int id with time.time()
star-nox Sep 12, 2023
ad581c8
handled ID type errors
star-nox Sep 12, 2023
34ba4dd
added timestamps to metadata
star-nox Sep 13, 2023
aee14dd
removed test files
star-nox Sep 13, 2023
c321225
testing for json error
star-nox Sep 13, 2023
fb37eed
testing for json error
star-nox Sep 13, 2023
90cdc5d
testing index errors
star-nox Sep 14, 2023
c20d5e2
fixed timestamp formats for nomic logs
star-nox Sep 14, 2023
65eddd9
checking for JSON serialization errors
star-nox Sep 15, 2023
041ff06
checking for JSON serialization errors
star-nox Sep 15, 2023
5a84764
typecasted previous convo ID to string for deletion
star-nox Sep 15, 2023
fe0de52
Yapf format ONLY
KastanDay Sep 15, 2023
adb1b50
revert all files with no changes except whitespace on newlines
KastanDay Sep 15, 2023
cf22849
cleanup prints, looks good to me
KastanDay Sep 15, 2023
b461282
minor cleanup of when logging happens
KastanDay Sep 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions ai_ta_backend/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import gc
import json
import os
import time
from typing import List
Expand All @@ -9,7 +10,7 @@
from flask_executor import Executor
from sqlalchemy import JSON

from ai_ta_backend.nomic_logging import get_nomic_map, log_query_to_nomic
from ai_ta_backend.nomic_logging import get_nomic_map, log_convo_to_nomic
from ai_ta_backend.vector_database import Ingest
from ai_ta_backend.web_scrape import main_crawler, mit_course_download

Expand Down Expand Up @@ -137,16 +138,13 @@ def getTopContexts() -> Response:
abort(
400,
description=
f"Missing one or me required parameters: 'search_query' and 'course_name' must be provided. Search query: `{search_query}`, Course name: `{course_name}`"
f"Missing one or more required parameters: 'search_query' and 'course_name' must be provided. Search query: `{search_query}`, Course name: `{course_name}`"
)

ingester = Ingest()
found_documents = ingester.getTopContexts(search_query, course_name, token_limit)
del ingester

# background execution of tasks!!
executor.submit(log_query_to_nomic, course_name, search_query)

response = jsonify(found_documents)
response.headers.add('Access-Control-Allow-Origin', '*')
return response
Expand Down Expand Up @@ -342,6 +340,7 @@ def scrape() -> Response:
print(f"Max Urls: {max_urls}")
print(f"Max Depth: {max_depth}")
print(f"Timeout in Seconds ⏰: {timeout}")
print(f"Stay on baseurl: {stay_on_baseurl}")

success_fail_dict = main_crawler(url, course_name, max_urls, max_depth, timeout, stay_on_baseurl)

Expand All @@ -350,7 +349,6 @@ def scrape() -> Response:
gc.collect() # manually invoke garbage collection, try to reduce memory on Railway $$$
return response


@app.route('/mit-download', methods=['GET'])
def mit_download_course() -> Response:
""" Web scraper built for
Expand Down Expand Up @@ -392,6 +390,26 @@ def nomic_map():
response.headers.add('Access-Control-Allow-Origin', '*')
return response

@app.route('/onResponseCompletion', methods=['POST'])
def logToNomic():
data = request.get_json()
course_name = data['course_name']
conversation = data['conversation']
if course_name == '' or conversation == '':
# proper web error "400 Bad request"
abort(
400,
description=
f"Missing one or more required parameters: 'course_name' and 'conversation' must be provided. Course name: `{course_name}`, Conversation: `{conversation}`"
)
print(f"In /onResponseCompletion for course: {course_name}")

# background execution of tasks!!
response = executor.submit(log_convo_to_nomic, course_name, data)
response = jsonify({'outcome': 'success'})
response.headers.add('Access-Control-Allow-Origin', '*')
return response


if __name__ == '__main__':
app.run(debug=True, port=int(os.getenv("PORT", default=8000)))
Loading