You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using litellm with pyright, the linter complains about type errors.
Examples:
Dictionary access linting error:
importlitellmresponse=litellm.completion(
model="gpt-3.5-turbo",
messages=[{"content": "Hello, how are you?", "role": "user"}],
max_tokens=10,
)
print(response["choices"][0]["message"]["content"])
# Error: "__getitem__" method not defined on type "CustomStreamWrapper"# (variable) response: ModelResponse | CustomStreamWrapper
Attribute access linting error:
print(response.choices[0].message.content)
# Cannot access attribute "choices" for class "CustomStreamWrapper"# Error: # - Attribute "choices" is unknown# (variable) choices: List[Choices | StreamingChoices] | Unknown# The list of completion choices the model generated for the input prompt.# - Cannot access attribute "message" for class "StreamingChoices"# Attribute "message" is unknown
Streaming linting error:
importasyncioimportosimporttracebackfromlitellmimportacompletionasyncdefcompletion_call():
try:
print("test completion + streaming")
response=awaitacompletion(
model="gpt-3.5-turbo",
messages=[{"content": "Hello, how are you?", "role": "user"}],
stream=True,
)
asyncforchunkinresponse:
# Error: "ModelResponse" is not iterable# "__aiter__" method not defined# (variable) response: ModelResponse | CustomStreamWrapperprint(chunk)
except:
print(f"error occurred: {traceback.format_exc()}")
passasyncio.run(completion_call())
What happened?
Issue:
When using litellm with pyright, the linter complains about type errors.
Examples:
Dictionary access linting error:
Attribute access linting error:
Streaming linting error:
Related Issues:
#2006
Relevant log output
Are you a ML Ops Team?
No
What LiteLLM version are you on ?
v1.60.5
Twitter / LinkedIn details
No response
The text was updated successfully, but these errors were encountered: