BerriAI / litellm

Python SDK, Proxy Server to call 100+ LLM APIs using the OpenAI format - [Bedrock, Azure, OpenAI, VertexAI, Cohere, Anthropic, Sagemaker, HuggingFace, Replicate, Groq]
https://docs.litellm.ai/docs/
Other
11.54k stars 1.33k forks source link

[Feature]: Add full type annotations for the library #825

Open ishaan-jaff opened 9 months ago

ishaan-jaff commented 9 months ago

The Feature

Screenshot 2023-11-15 at 12 44 30 PM

you have some basic typing but I mean actually having models or even TypedDicts for all the parameters. Here is the current completion signature attached, where "messages" and "functions" are just typed as "List". My type checker shows an issue because it's unknown what's in the list

Motivation, pitch

user request

Twitter / LinkedIn details

No response

ishaan-jaff commented 9 months ago

ideally those properties are in the code as models.

So you would have something like: messages: list[MessageModel], functions: list[FunctionModel]

And the MessageModel could look like:

class MessageModel(TypedDict): role: str content: str | None name: string | None function_call: FunctionCall | None

JamesHutchison commented 5 months ago

Is this completed? Is it just missing the py.typed marker?

ishaan-jaff commented 5 months ago

Nope - open to contributions on this @JamesHutchison

krrishdholakia commented 5 months ago

this contribution would be very appreciated @JamesHutchison

edwinjosegeorge commented 3 months ago

@ishaan-jaff could you have a look at the PR. Did you meant annotating with the TypedDict? I referenced the OpenAI spec to replicate the type check.

edwinjosegeorge commented 3 months ago

I find couple of existing issues that have similar objective, Improving code quality by adding type annotations.

I am interested to work on it. See https://github.com/BerriAI/litellm/pull/3291

krrishdholakia commented 3 months ago

please help here - this would be very useful @edwinjosegeorge