Closed dylanshine closed 1 year ago
FYI: The previous implementation was probably fine for 95%+ of the use cases. The memory leak only occurred when releasing openAIKit while the app is running. Most implementations probably never released the client until the app shuts downs.
One thing I've been thinking of is the possibility of overriding the default URL in case you want to use a proxy. With that, an example AWS Lambda implementation would be good to include. However, for GPT4 we'd really need streaming. GPT4 is too slow and AWS Gateway will timeout. Maybe we could add a AWS lambda example, restructure the HTTP client and implement streaming next.
I don't have any strong opinion about how to do that and I'm not super familiar with Nio. Is your suggestion to use URLSession instead of Nio or can URLSession be used on top of Nio?
Being able to configure URLs should be an easy change as just an extra parameter when initializing the OpenAIKit client. Let me take a stab at that here
@dylanshine Awesome! If you have a chance, please do check the other Nio-based project that has working steaming. I'd be happy to take a stab at it, but since you're more experienced with Nio, you probably will be able to add streaming much faster than I can. I can't stress enough how important steaming is for GPT4. People are literally asking why the app is so slow https://twitter.com/imkevinxu/status/1640192636236730370?s=20
@ronaldmannak Can you link the project here?
@dylanshine absolutely, I mentioned it here: https://github.com/dylanshine/openai-kit/issues/15#issuecomment-1481798156
@ronaldmannak Take a look at https://github.com/dylanshine/openai-kit/pull/38 and lmk if it fits your needs mentioned in https://github.com/dylanshine/openai-kit/issues/30#issuecomment-1485470182
https://github.com/dylanshine/openai-kit/releases/tag/1.8.0 supports URLSession
@ronaldmannak I was thinking based on your last contribution, that it might make sense to restructure the use of AsyncHTTPClient to clean up usage. I was also thinking it might make sense to potentially allow passing either an AsyncHTTPClient or URLSession in order to perform the requests. Haven't really sat down to think this through, but I'd be curious to hear your thoughts.