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

Fixing an issue with per file settings. #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lukolszewski
Copy link

This is in relation to #4
I noticed theer was code to get stuff from notebook.metadata.parameters and put it in the options field of OpenAI api request. I wanted a per file ability to specify endpoints (to use different models, including self hosted ones) so I added this code to handle an extra object under parametrs called settings. If it contains property of endpoint or model, it will override global config. Then settings is deleted and the rest of parameters is handled the same as before.

Hopefully it is of use to someone.

@JacksonKearl
Copy link
Owner

JacksonKearl commented Jan 18, 2024

Thanks for looking into this. The model parameter is already overridable by the options, the endpoint is the only thing that needs changing.

const model = config.get<string>("model") ?? "gpt-3.5-turbo"
const endpoint =
let model = config.get<string>("model") ?? "gpt-3.5-turbo"
let endpoint =
config.get<string>("endpoint") ??
"https://api.openai.com/v1/chat/completions"

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe just

 const endpoint =
      notebook.metadata.parameters?.settings?.endpoint ??
      config.get<string>("endpoint") ??
      "https://api.openai.com/v1/chat/completions"

?

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.

2 participants