signebedi / gptty

ChatGPT wrapper in your TTY
MIT License
47 stars 7 forks source link

[model] add support for chatcompletion models #31

Closed signebedi closed 1 year ago

signebedi commented 1 year ago

add support for chatcompletion models Currently, we only support completion models. Subsequently, we will need to find a way to support chat completion too.

References

  1. chat completion source code python https://github.com/openai/openai-python/blob/main/openai/api_resources/chat_completion.py#L8
  2. chat completion create https://platform.openai.com/docs/api-reference/chat/create
  3. chat completions general introduction https://platform.openai.com/docs/guides/chat
  4. list of models https://platform.openai.com/docs/models/overview

Originally posted by @signebedi in https://github.com/signebedi/gptty/issues/30#issuecomment-1486193866

signebedi commented 1 year ago

[model] extend keyword tokenization to ChatCompletion models Currently, keyword tokenization (and context structuring generally) is limited to Completion models. We should update the context logic to correctly structure ChatCompletion messages:

  messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "Who won the world series in 2020?"},
        {"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
        {"role": "user", "content": "Where was it played?"}
    ]