-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
400 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: GitHub Actions Demo | ||
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀 | ||
on: [push] | ||
jobs: | ||
Explore-GitHub-Actions: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
- name: Check out repository code | ||
uses: actions/checkout@v4 | ||
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner." | ||
- run: echo "🖥️ The workflow is now ready to test your code on the runner." | ||
- name: List files in the repository | ||
run: | | ||
ls ${{ github.workspace }} | ||
- run: echo "🍏 This job's status is ${{ job.status }}." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
from flask import Flask, request, jsonify | ||
import os | ||
from dotenv import load_dotenv | ||
from lib import chat_completion_request, create_embedding | ||
import json | ||
|
||
from pymongo.mongo_client import MongoClient | ||
|
||
uri = "mongodb+srv://bluebookairoot:<password>@bluebookcluster.0hf4pzi.mongodb.net/?retryWrites=true&w=majority&appName=BluebookCluster" | ||
|
||
# connect to the MongoDB cluster | ||
client = MongoClient(uri) | ||
db = client['bluebookai'] | ||
collection = db['course-info'] | ||
|
||
try: | ||
client.admin.command('ping') | ||
print("Pinged your deployment. You successfully connected to MongoDB!") | ||
except Exception as e: | ||
print(e) | ||
|
||
app = Flask(__name__) | ||
|
||
load_dotenv() | ||
|
||
@app.route('/chat', methods=['POST']) | ||
def chat(): | ||
data = request.get_json() | ||
if 'message' not in data: | ||
return jsonify({"error": "Missing 'messages' in request body"}), 400 | ||
|
||
user_messages = data['message'] | ||
response = chat_completion_request(messages=user_messages) | ||
message = response.choices[0].message | ||
print(message) | ||
# if message.tool_calls is None: | ||
# return 'success' | ||
# args = json.loads(message.tool_calls[0].function.arguments) | ||
# query_vector = create_embedding(user_messages[-1]['content']) | ||
# database_response = collection.aggregate([ | ||
# { | ||
# '$vectorSearch': { | ||
# 'index': 'course-rating-index', | ||
# 'path': 'embedding', | ||
# 'filter': { | ||
# 'rating': { | ||
# args['operator']: args['rating'] | ||
# } | ||
# }, | ||
# 'queryVector': query_vector, | ||
# 'numCandidates': 5, | ||
# 'limit': 5 | ||
# } | ||
# } | ||
# ]) | ||
# # print(database_response) | ||
|
||
# top_class = list(database_response)[0] | ||
# json_response = { | ||
# 'title': top_class['title'], | ||
# 'rating': top_class['rating'], | ||
# } | ||
# return jsonify(json_response) | ||
|
||
# "{\"operator\":\"$gt\",\"rating\":4}" | ||
|
||
# ChatCompletionMessage(content=None, role='assistant', function_call=None, tool_calls=[ChatCompletionMessageToolCall(id='call_Ub07GeA6kaC2OZ8b8KlVmtZz', function=Function(arguments='{\n "subject_code": "CPSC",\n "rating": 3.5,\n "comparison_operator_rating": "$gte",\n "workload": 1,\n "comparison_operator_workload": "$lte"\n}', name='CourseFilter'), type='function')]) | ||
|
||
query_vector = create_embedding(user_messages[-1]['content']) | ||
|
||
print(user_messages[-1]) | ||
database_response = collection.aggregate([ | ||
{ | ||
'$vectorSearch': { | ||
'index': 'course-rating-index', | ||
'path': 'embedding', | ||
'queryVector': query_vector, | ||
'numCandidates': 5, | ||
'limit': 5 | ||
} | ||
} | ||
]) | ||
|
||
classes = list(database_response) | ||
# top_class = classes[0] | ||
print([c['title'] for c in classes]) | ||
top_class = classes[0] | ||
json_response = { | ||
# 'message': [{ | ||
# 'role': response.choices[0].message.role, | ||
# 'content': response.choices[0].message.content, | ||
# }] | ||
'title': top_class['title'], | ||
# 'rating': top_class['rating'], | ||
} | ||
|
||
return jsonify(json_response) | ||
|
||
if __name__ == '__main__': | ||
app.run(debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
{ | ||
"ACCT": "Accounting", | ||
"USAF": "Aerospace Studies", | ||
"AFAM": "African American Studies", | ||
"AFST": "African Studies", | ||
"AKKD": "Akkadian", | ||
"ASL": "American Sign Language", | ||
"AMST": "American Studies", | ||
"GREK": "Ancient Greek", | ||
"ANTH": "Anthropology", | ||
"AMTH": "Applied Mathematics", | ||
"APHY": "Applied Physics", | ||
"ARBC": "Arabic", | ||
"ARCG": "Archaeological Studies", | ||
"ARCH": "Architecture", | ||
"ARMN": "Armenian", | ||
"ART": "Art", | ||
"ASTR": "Astronomy", | ||
"BNGL": "Bengali", | ||
"B&BS": "Biological & Biomedical Sci", | ||
"BIOL": "Biology", | ||
"BENG": "Biomedical Engineering", | ||
"BIS": "Biostatistics", | ||
"BRST": "British Studies", | ||
"BURM": "Burmese", | ||
"C&MP": "Cell & Molecular Physiology", | ||
"CBIO": "Cell Biology", | ||
"CENG": "Chemical Engineering", | ||
"CHEM": "Chemistry", | ||
"CHER": "Cherokee", | ||
"CHLD": "Child Study", | ||
"CHNS": "Chinese", | ||
"CDE": "Chronic Disease Epidemiology", | ||
"CLCV": "Classical Civilization", | ||
"CLSS": "Classics", | ||
"MEDR": "Clinical Clerkships", | ||
"CGSC": "Cognitive Science", | ||
"CSYC": "Coll Sem: Yale Coll", | ||
"CSBF": "Coll Sem:Ben Franklin Coll", | ||
"CSBK": "Coll Sem:Berkeley Coll", | ||
"CSBR": "Coll Sem:Branford Coll", | ||
"CSDC": "Coll Sem:Davenport Coll", | ||
"CSES": "Coll Sem:Ezra Stiles Coll", | ||
"CSGH": "Coll Sem:Grace Hopper Coll", | ||
"CSJE": "Coll Sem:Jonathan Edwards Coll", | ||
"CSMC": "Coll Sem:Morse Coll", | ||
"CSMY": "Coll Sem:Pauli Murray Coll", | ||
"CSPC": "Coll Sem:Pierson Coll", | ||
"CSSY": "Coll Sem:Saybrook Coll", | ||
"CSSM": "Coll Sem:Silliman Coll", | ||
"CSTD": "Coll Sem:Timothy Dwight Coll", | ||
"CSTC": "Coll Sem:Trumbull Coll", | ||
"CB&B": "Comp Biol & Bioinfomatics", | ||
"CPLT": "Comparative Literature", | ||
"CPSC": "Computer Science", | ||
"CSEC": "Computer Science and Economics", | ||
"CPAR": "Computing and the Arts", | ||
"MEDC": "Courses in School of Medicine", | ||
"CZEC": "Czech", | ||
"DEVN": "DeVane Lecture Course", | ||
"DRST": "Directed Studies", | ||
"DIR": "Directing", | ||
"DISR": "Diss Research - in Residence", | ||
"DRAM": "Drama", | ||
"DRMA": "Drama Summer", | ||
"DUTC": "Dutch", | ||
"EMST": "Early Modern Studies", | ||
"EPS": "Earth and Planetary Sciences", | ||
"EALL": "East Asian Lang and Lit", | ||
"EAST": "East Asian Studies", | ||
"E&EB": "Ecology & Evolutionary Biology", | ||
"ECON": "Economics", | ||
"EDST": "Education Studies", | ||
"EGYP": "Egyptology", | ||
"EENG": "Electrical Engineering", | ||
"ENRG": "Energy Studies", | ||
"ENAS": "Engineering & Applied Science", | ||
"ENGL": "English", | ||
"ELP": "English Language Program", | ||
"ENV": "Environment", | ||
"ENVE": "Environmental Engineering", | ||
"EHS": "Environmental Health Sciences", | ||
"EVST": "Environmental Studies", | ||
"EPH": "Epidemiology & Public Health", | ||
"EMD": "Epidemiology Microbial Disease", | ||
"EP&E": "Ethics, Politics, & Economics", | ||
"ER&M": "Ethnicity, Race, & Migration", | ||
"E&RS": "European & Russian Studies", | ||
"EXCH": "Exchange Scholar Experience", | ||
"EXPA": "Experimental Pathology", | ||
"FILM": "Film & Media Studies", | ||
"FNSH": "Finnish", | ||
"F&ES": "Forestry & Environment Studies", | ||
"FREN": "French", | ||
"GENE": "Genetics", | ||
"G&G": "Geology and Geophysics", | ||
"GMAN": "German", | ||
"GLBL": "Global Affairs", | ||
"HPM": "Health Policy and Management", | ||
"HLTH": "Health Studies", | ||
"HEBR": "Hebrew", | ||
"HNDI": "Hindi", | ||
"HSHM": "Hist of Science, Hist of Med", | ||
"HIST": "History", | ||
"HSAR": "History of Art", | ||
"HMRT": "Human Rights", | ||
"HUMS": "Humanities", | ||
"HGRN": "Hungarian", | ||
"IBIO": "Immunobiology", | ||
"IDRS": "Ind Res in Sciences", | ||
"INDN": "Indonesian", | ||
"INP": "Interdpt Neuroscience Pgm", | ||
"IMED": "Investigative Medicine", | ||
"ITAL": "Italian Studies", | ||
"JAPN": "Japanese", | ||
"JDST": "Jewish Studies", | ||
"KHMR": "Khmer", | ||
"SWAH": "Kiswahili", | ||
"KREN": "Korean", | ||
"LATN": "Latin", | ||
"LAST": "Latin American Studies", | ||
"LAW": "Law", | ||
"LING": "Linguistics", | ||
"LITR": "Literature", | ||
"MGT": "Management", | ||
"MGMT": "Management, PhD", | ||
"MRES": "Master's Thesis Research", | ||
"MHHR": "Material Hist of Human Record", | ||
"MATH": "Mathematics", | ||
"MENG": "Mechanical Engineering", | ||
"MDVL": "Medieval Studies", | ||
"MESO": "Mesopotamia", | ||
"MBIO": "Microbiology", | ||
"MGRK": "Modern Greek", | ||
"MMES": "Modern Middle East Studies", | ||
"MTBT": "Modern Tibetan", | ||
"MB&B": "Molecular Biophysics & Biochem", | ||
"MCDB": "Molecular, Cellular & Dev Biol", | ||
"MUSI": "Music Department", | ||
"NAVY": "Naval Science", | ||
"NELC": "Near Eastern Langs & Civs", | ||
"NPLI": "Nepali", | ||
"NSCI": "Neuroscience", | ||
"NURS": "Nursing", | ||
"OTTM": "Ottoman", | ||
"PATH": "Pathology", | ||
"PERS": "Persian", | ||
"PHAR": "Pharmacology", | ||
"PHIL": "Philosophy", | ||
"OLPA": "Physician Assistant Online Pgm", | ||
"PA": "Physician Associate Program", | ||
"PHYS": "Physics", | ||
"PLSH": "Polish", | ||
"PLSC": "Political Science", | ||
"PORT": "Portuguese", | ||
"PRAC": "Practicum Analysis", | ||
"CAND": "Prep for Adv to Candidacy", | ||
"QUAL": "Preparing for Qualifying Exams", | ||
"PSYC": "Psychology", | ||
"PHUM": "Public Humanities", | ||
"PNJB": "Punjabi", | ||
"REL": "Religion", | ||
"RLST": "Religious Studies", | ||
"RNST": "Renaissance Studies", | ||
"ROMN": "Romanian", | ||
"RUSS": "Russian", | ||
"RSEE": "Russian & East Europe Studies", | ||
"SKRT": "Sanskrit", | ||
"MD": "School of Medicine", | ||
"MUS": "School of Music", | ||
"SCIE": "Science", | ||
"SMTC": "Semitic", | ||
"SBCR": "Serbian & Croatian", | ||
"SNHL": "Sinhala", | ||
"SLAV": "Slavic", | ||
"SBS": "Social and Behavioral Sciences", | ||
"SOCY": "Sociology", | ||
"SAST": "South Asian Studies", | ||
"SPAN": "Spanish", | ||
"SPEC": "Special Divisional Major", | ||
"STRT": "Start Program - Medical School", | ||
"S&DS": "Statistics and Data Sciences", | ||
"STEV": "Studies in the Environment", | ||
"STCY": "Study of the City", | ||
"SUMR": "Summer Term", | ||
"SWED": "Swedish", | ||
"TAML": "Tamil", | ||
"THST": "Theater and Performance Studies", | ||
"TBTN": "Tibetan", | ||
"PTB": "Translational Biomedicine", | ||
"TKSH": "Turkish", | ||
"TWI": "Twi", | ||
"UKRN": "Ukrainian", | ||
"URBN": "Urban Studies", | ||
"VIET": "Vietnamese", | ||
"VAIR": "Visiting Assistant in Research", | ||
"WLOF": "Wolof", | ||
"WGSS": "Women's, Gender & Sexuality Studies", | ||
"YDSH": "Yiddish", | ||
"YORU": "Yoruba", | ||
"ZULU": "Zulu" | ||
} |
Oops, something went wrong.