Skip to content

Code changes for your consideration #74

@markphaedrus

Description

@markphaedrus

Hey! I got interested in poking into this again with all the new OpenAI models coming out, so I made some code changes that you might be interested in looking at. Have a look at the commit pushed to the fork https://github.com/markphaedrus/OpenCharacters .

Summary of the changes:

  • Updated the list of OpenAI broadly-available models.
  • Model selector in the character editing page, and model selector in the thread window, now include pricing info. A little warning icon is displayed next to the model selector in the thread window if the pricing data is too stale.
  • Updated the default model choices to reflect what seemed like the most plausible choices in the current model set.
  • Added error handling for cases where a thread is using models that aren't supported anymore.
  • Tweaked the embedding code so that the subtraction from the calculated distances is model-specific, since the newer and cheaper text-embedding-3-small gives a very different range of values than what text-embedding-ada-002 did.
  • Added logic to avoid feeding temperature selections into models that don't support them (some of the new models don't, and throw errors if you try).
  • Likewise, added logic to change max_tokens to max_completion_tokens on a model-by-model basis, because some models don't support max_tokens and cry if you try to use it.
  • Updated the default characters so they use the current "good" model instead of a hardcoded choice.
  • Removed the gpt-4-specific "can we run this model?" check, since it didn't seem to be working when I tried to apply it to the current still-in-testing model.
  • Token-counting just uses the GPT-3 tokenizer for all OpenAPI models, because honestly I wouldn't even know where to begin updating the tokenizer.
  • Added code to let models specify an instruction-to-AI role other than "system", because at first it seemed like some of the new models didn't behave correctly unless I changed the role from "system" to "developer". That turned out to apparently not be true, so everything still uses "system", but I left the code in place just in case.
  • Added a "/flushembeds" command, to clear out the text embedding cache. Updated the tooltip in the thread input box.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions