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

Feat/open ai gateway #150

Merged
merged 7 commits into from
Feb 26, 2025
Merged

Feat/open ai gateway #150

merged 7 commits into from
Feb 26, 2025

Conversation

wally-yawn
Copy link
Collaborator

Notes

This adds several gems and updates the credentials file. Pulling this down you will need to do a bundle install and get the updated master key from @epintozzi .

Type of Change

  • feature ⛲
  • testing 🧪

Description

This adds a gateway for our application to make a call to openai's api to generate practice interview questions for a given job description.

Motivation and Context

This opens up our application to be able to make calls to openai so that that information can be provided to the front-end to display to the user. This is a sub-issue of the larger epic to make use of those here:
#142

Related Tickets

closes #145

Screenshots (if appropriate):

Added Test?

  • Yes 🫡
  • All previous tests still pass 🥳

Checklist:

  • My code follows the code style of this project.

c.cassette_library_dir = "spec/cassettes"
c.hook_into :webmock
c.configure_rspec_metadata!
c.filter_sensitive_data('<OPENAI_API_KEY>') { Rails.application.credentials.dig(:open_ai, :key) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for ensuring the key is redacted from the cassettes ❤️

Copy link
Collaborator

@kaelinpsalazar kaelinpsalazar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to get it to return data. Its saying I need to provide an API key. Should that be the case?

@epintozzi
Copy link
Contributor

I am trying to get it to return data. Its saying I need to provide an API key. Should that be the case?

Have you added the master.key file yet? If not, I expect that would resolve the issue for you.

Copy link
Collaborator

@sethverrill sethverrill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything here looks really great.
Could someone add a line to the README to give instructions on installing a BE yml for OpenAI so everyone doesn't need to go to their docs?


def build_prompt(description)
"Please generate 10 practice interview questions based on the following job description: #{description}.
ONLY return a JSON array of strings containing the questions, with no additional formatting or object keys."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is built really cleanly. Easy to follow logic. Easy to follow errors.
I tried your prompt in ChatGPT and got 10 really good responses, so I think the wording should work great.


expect(response[:success]).to eq(false)
expect(response[:error]).to include("An error occurred: Something went wrong")
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing looks really thorough. I went through you object and line coverage looks great.

@wally-yawn
Copy link
Collaborator Author

I am trying to get it to return data. Its saying I need to provide an API key. Should that be the case?

sent the master.key in dm then deleted the dm

@wally-yawn
Copy link
Collaborator Author

wally-yawn commented Feb 26, 2025

Everything here looks really great. Could someone add a line to the README to give instructions on installing a BE yml for OpenAI so everyone doesn't need to go to their docs?

I think we'll add info to the readme as part of Kaelin's work that finishes the backend implementation, we'll be able to be more complete when that is finished

@kaelinpsalazar
Copy link
Collaborator

I am trying to get it to return data. Its saying I need to provide an API key. Should that be the case?

Have you added the master.key file yet? If not, I expect that would resolve the issue for you.

I got together with wally and get it running on my end. Thanks for the tip!

@sethverrill
Copy link
Collaborator

Everything here looks really great. Could someone add a line to the README to give instructions on installing a BE yml for OpenAI so everyone doesn't need to go to their docs?

I think we'll add info to the readme as part of Kaelin's work that finishes the backend implementation, we'll be able to be more complete when that is finished

Sounds good. Approving now

Copy link
Collaborator

@kaelinpsalazar kaelinpsalazar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to get it to return data. Its saying I need to provide an API key. Should that be the case?

*Update: I got it working. This all looks great.

expect(gateway_response[:data][2]).to eq("How do you approach writing clean and maintainable code?")
end
end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice comprehensive testing. I can't think of edge cases that you aren't covering.

{ success: false, error: "An error occurred: #{error.message}" }

end

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it to pull down sample interview questions, after a little issue on my end with the key. Great job!

@kaelinpsalazar kaelinpsalazar merged commit 243aefc into main Feb 26, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gateway to chatgpi api
4 participants