microsoft / promptflow

Build high-quality LLM apps - from prototyping, testing to production deployment and monitoring.
https://microsoft.github.io/promptflow/
MIT License
8.43k stars 725 forks source link

[Feature Request] relax openai version constraint to support 1.x #1019

Closed wangchao1230 closed 6 months ago

wangchao1230 commented 6 months ago

Is your feature request related to a problem? Please describe.

image

Describe the solution you'd like relax open ai version constraint image

Additional context Add any other context or screenshots about the feature request here.

AreChen commented 6 months ago

After updating the openai library to version 1.1.1,

invoke using the latest method.

from openai import OpenAI
client = OpenAI()

completion = client.chat.completions.create(
  model="gpt-3.5-turbo-1106",
  messages=[
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Hello!"}
  ]
)

Running will result in an error.

 File "C:\ProgramData\miniconda3\Lib\site-packages\promptflow\_core\openai_injector.py", line 131, in inject_openai_api
    openai.api_key_path = os.environ.get("OPENAI_API_KEY_PATH", openai.api_key_path)
                                                                ^^^^^^^^^^^^^^^^^^^
AttributeError: module 'openai' has no attribute 'api_key_path'
AreChen commented 6 months ago

The following two lines in the openai_injector.py annotation can work properly.

openai.api_key_path = os.environ.get("OPENAI_API_KEY_PATH", openai.api_key_path)
openai.api_base = os.environ.get("OPENAI_API_BASE", openai.api_base)
thy09 commented 6 months ago

@AreChen Thanks for reporting this, we opened a PR for this: https://github.com/microsoft/promptflow/pull/1072 Then the execution of python scripts will not be blocked.

wangchao1230 commented 6 months ago

@thy09 we shall also relax the version contraint in setup.py

thy09 commented 6 months ago

@wangchao1230 Will do that when most stuffs are ready.

pamelafox commented 6 months ago

Is it possible for now to loosen it to even allow 0.28.1, the one right before 1.0? https://pypi.org/project/openai/0.28.1/ Currently your setup.py requires "openai<0.28.0" and I'm not sure why 0.28.0/0.28.1 wouldn't be okay.

thy09 commented 6 months ago

Hi @pamelafox we are going to remove the constraint in the next release, is it OK for you?

pamelafox commented 6 months ago

That'd be fine as well. I ended up removing promptflow as a dependency entirely, as it also has upper version constraints on Flask that are incompatible with our app. It'd be great if you could relax as many upper version constraints as possible. See reasoning in: https://iscinumpy.dev/post/bound-version-constraints/

thy09 commented 6 months ago

@pamelafox The reason we pin some package versions is that we met some issue when some dependency updates. If you have concern of the version of flask, you may create another issue for it so we can track this.

lumoslnt commented 6 months ago

We have relaxed the OpenAI version constraint and supported the OpenAI V1 in promptflow 1.1.0 and promptflow-tools 1.0.0, closing this issue.