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

Feature Request: Add a Parameter to Return Messages as Strings Instead of Objects #165

Open
sheng-di opened this issue Mar 16, 2024 · 2 comments

Comments

@sheng-di
Copy link

sheng-di commented Mar 16, 2024

Hello @anasfik,

Firstly, I want to express my appreciation for your work on the 'openai' project. It's been incredibly useful and well implemented.

I am writing to suggest a feature that could enhance the adaptability of the project with different GPT proxies. Currently, the 'messages' field in the request body is an array of objects, each containing 'type' and 'text' fields, like so:

{
  "model": "gpt-4",
  "messages": [
    {
      "role": "system",
      "content": [
        { "type": "text", "text": "return any message you are given as JSON." }
      ]
    },
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Hello, I am a chatbot created by OpenAI. How are you today?"
        }
      ]
    }
  ]
}

However, some GPT proxies only support strings and not objects. Therefore, it would be beneficial if we could have an option to set a parameter that changes the 'messages' field to only contain strings. For example, by setting OpenAI.onlyString = true;, the 'messages' content would be transformed into:

{
  "model": "gpt-4",
  "messages": [
    {
      "role": "system",
      "content": [
        "return any message you are given as JSON."
      ]
    },
    {
      "role": "user",
      "content": [
        "Hello, I am a chatbot created by OpenAI. How are you today?"
      ]
    }
  ]
}

Implementing this feature would increase the project's compatibility with various GPT proxies, making it more versatile and user-friendly. I believe this would be a valuable addition to the project.

Thank you for considering this suggestion. I look forward to your feedback.

@sheng-di
Copy link
Author

@anasfik
Copy link
Owner

anasfik commented May 8, 2024

The package is made to reflect the OpenAI APIs, which I take to be my responsibility on this project.

rather than having this built in, have a custom proxying of the stream of completion, the map() on a dart Stream is what you need here to make the original response adapt to GPT proxies.

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

No branches or pull requests

2 participants