Skip to content

Commit

Permalink
test qa_supplement flow
Browse files Browse the repository at this point in the history
  • Loading branch information
seplee committed Apr 14, 2024
1 parent 4679496 commit 0706613
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 16 deletions.
14 changes: 1 addition & 13 deletions api/backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ def login():

# Use library to construct the request for Google login and provide
# scopes that let you retrieve user's profile from Google
redirect_uri = "https://drive-gooder.com/api/login"
# print(f'callback uri: {request.base_url + "/callback"}')
print(f'callback uri: {request.base_url + "/callback"}')
request_uri = client.prepare_request_uri(
authorization_endpoint,
Expand All @@ -144,9 +142,6 @@ def login():

@app.route("/api/login/callback")
def callback():
print("I think both of the below urls need to use https")
print(f"request url: {request.url}")
print(f"request base url: {request.base_url}")
print("got to the callback, friendo")
# Get authorization code Google sent back to you
code = request.args.get("code")
Expand All @@ -155,7 +150,6 @@ def callback():
# things on behalf of a user
google_provider_cfg = get_google_provider_cfg()
token_endpoint = google_provider_cfg["token_endpoint"]
print(f"token endpoint {token_endpoint}")
# Prepare and send a request to get tokens! Yay tokens!
token_url, headers, body = client.prepare_token_request(
token_endpoint,
Expand All @@ -170,20 +164,16 @@ def callback():
data=body,
auth=(GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET),
)
print(f"we probably get to here before the error")

# Parse the tokens!
client.parse_request_body_response(json.dumps(token_response.json()))
print(f"I don't expect to see this message.")


# Now that you have tokens (yay) let's find and hit the URL
# from Google that gives you the user's profile information,
# including their Google profile image and email
userinfo_endpoint = google_provider_cfg["userinfo_endpoint"]
uri, headers, body = client.add_token(userinfo_endpoint)
print(f"improbably, we have added a token")
userinfo_response = requests.get(uri, headers=headers, data=body)
print(f"perhaps it fails after userinfo_response")

# You want to make sure their email is verified.
# The user authenticated with Google, authorized your
Expand All @@ -210,10 +200,8 @@ def callback():
# Begin user session by logging the user in
loginSuccess = login_user(user, remember=True)
print(f'login succeeded: {loginSuccess}')

print(f'current user: {current_user}')

print(f'cookie:\n{request.cookies}')
# Send user back to homepage
return redirect(ROOT_URI)
# when the user logs in on the frontend, give them a session id
Expand Down
5 changes: 2 additions & 3 deletions api/backend/llm/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
summarize_model = environ["SUMMARIZE_MODEL"].lower()
speech_to_text_model = environ["SPEECH_TO_TEXT_MODEL"].lower()
text_to_speech_model = environ["TEXT_TO_SPEECH_MODEL"].lower()
question_model = environ["QUESTION_MODEL"].lower()


def build_summarizer():
Expand Down Expand Up @@ -37,8 +36,8 @@ def build_text_to_speech():
raise Exception("Unsupported TEXT_TO_SPEECH_MODEL value")


def build_supplementary_info():
match question_model:
def build_supplementary_info(question_type):
match question_type:
case "research_paper":
return arxiv_supplementary_info
raise Exception("Unsupported supplementary_info value")

0 comments on commit 0706613

Please sign in to comment.