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

not-an-iterable in openai chat completion #9318

Closed
lutzroeder opened this issue Dec 19, 2023 · 1 comment
Closed

not-an-iterable in openai chat completion #9318

lutzroeder opened this issue Dec 19, 2023 · 1 comment
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@lutzroeder
Copy link

lutzroeder commented Dec 19, 2023

Bug description

import openai

client = openai.OpenAI()

with open('test.txt', 'r', encoding='utf-8') as handle:
    contents = handle.read()

completion = client.chat.completions.create(
    model="gpt-4-1106-preview",
    messages = [ { "role":"user", "content": "Summarize\n\n" + contents } ],
    stream = True
)

for event in completion: # pylint: disable=not-an-iterable
    content = event.choices[0].delta.content
    print(content, end='', flush=True)

Configuration

[MASTER]
disable=
    C0103, # invalid-name
    C0114, # missing-module-docstring
    C0115, # missing-class-docstring
    C0116, # missing-function-docstring

[TYPECHECK]
generated-members=torch.*

Command used

pyline gpt-4-1106-preview.py

Pylint output

************* Module gpt-4-1106-preview
gpt-4-1106-preview.py:23:13: E1133: Non-iterable value completion is used in an iterating context (not-an-iterable)

Expected behavior

No warning.

Pylint version

ylint 3.0.3
astroid 3.0.1
Python 3.11.6 (main, Oct  2 2023, 13:45:54) [Clang 15.0.0 (clang-1500.0.40.1)]

OS / Environment

macOS 14.2

Additional dependencies

openai==1.5.0

Related issues

microsoft/pyright#6772
openai/openai-python#870

@lutzroeder lutzroeder added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Dec 19, 2023
@jacobtylerwalls
Copy link
Member

Thanks for the report. The library you're using uses @overload, which we don't support yet. Will close as a duplicate of pylint-dev/astroid#1015 / #5712

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2024
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

2 participants