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

LLM settings from url #121

Merged
merged 3 commits into from
Oct 25, 2023
Merged

LLM settings from url #121

merged 3 commits into from
Oct 25, 2023

Conversation

mruwnik
Copy link
Collaborator

@mruwnik mruwnik commented Oct 18, 2023

No description provided.


def formatter(item):
if isinstance(item, Exception):
item = {'state': 'error', 'error': str(item)}
return json.dumps(item)

def run(callback):
return run_query(session_id, query, history, Settings(**settings), callback)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the Settings class have various validators that can raise exceptions. This causes the request to fail with a uninformative (for the user) error, so make sure that a proper error instance is streamed back

streaming=True,
callbacks=callbacks,
max_tokens=settings.max_response_tokens,
model=settings.completions
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the model setting wasn't being used

@@ -30,3 +44,78 @@ export const A: React.FC<{
<a className={className}>{children}</a>
);
};

const between =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

these are just moved over from the playground.tsx file

SETTINGS_PARSERS
);

type ChatSettingsParams = {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the following lines are just moved over from playground.tsx

};
export const ENCODERS = ["cl100k_base"];

/** Update the given `obj` so that it has `val` at the given path.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

a bit of magic starts here - the idea is for each settings field to have a defined parser that will also return a default value if provided with an undefined value. Most of the magic is to handle the prompts, which are nested.
I considered just having separate keys for the prompt parts, but that would require a lot of messing around in other places, so I just kept the complexity here

const setMode = (mode: [Mode, boolean]) => {
if (mode[1]) {
localStorage.setItem("chat_mode", mode[0]);
updateSettings((settings) => ({ ...settings, mode: mode[0] }));
}
};

const changeSetting = (path: string[], value: any) => {
router.replace(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this will add any changes in the various widgets to the URL, so it'll be a lot easier to save/share parameters

@mruwnik
Copy link
Collaborator Author

mruwnik commented Oct 24, 2023

ping

@mruwnik mruwnik merged commit b03a95f into main Oct 25, 2023
1 check passed
@mruwnik mruwnik deleted the parametrized-url branch October 25, 2023 06:59
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