Open CharlieJCJ opened 1 week ago
Works for Claude model_name="claude-3-opus-20240229"
After #149's merge (that resolves #145), do performance comparison of litellm vs. OpenAI request processors
TODO
Need to add a better default timeout.
asyncio issue pops up
(bespokelabs-curator-py3.12) (base) ➜ bella git:(CURATOR-28-add-a-lite-llm-backend-for-curator) ✗ python examples/litellm_example.py
Processing LiteLLM requests: 98%|█████████████████████████████████████████████████████████████████████████████████████▎ | 98/100 [00:12<00:00, 8.06it/s]
title ... cuisine_type
0 \"Simple Pork and Rice\" ... Chinese
1 \"Simple Chicken and Vegetable Stir-fry\" ... Chinese
2 \"Ginger Chicken and Broccoli\" ... Chinese
3 Simple Pork and Rice ... Chinese
4 \"Ginger Chicken and Broccoli\" ... Chinese
.. ... ... ...
95 \"Ginger Chicken and Broccoli\" ... Chinese
96 \"Simple Chicken Fried Rice\" ... Chinese
97 Chinese Pork and Egg Fried Rice ... Chinese
98 Garlic Ginger Bok Choy and Carrot Rice ... Chinese
99 \"Simple Pork and Rice Stir-fry\" ... Chinese
[100 rows x 4 columns]
Processing LiteLLM requests: 0%| | 0/100 [00:00<?, ?it/s]
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
2024-11-22 01:17:48,949 - bespokelabs.curator.request_processor.litellm_online_request_processor - ERROR - Error in request 0: litellm.APIConnectionError: Event loop is closed
Traceback (most recent call last):
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/main.py", line 481, in acompletion
response = await init_response
^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/vertex_ai_and_google_ai_studio/gemini/vertex_and_google_ai_studio_gemini.py", line 1251, in async_completion
response = await client.post(api_base, headers=headers, json=request_body) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 166, in post
raise e
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 123, in post
response = await self.client.send(req, stream=stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1674, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1702, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1776, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 377, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 135, in handle_async_request
await self._response_closed()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 250, in _response_closed
await self.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 258, in aclose
await self._network_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
await self._stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 201, in aclose
await self.transport_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1287, in aclose
self._transport.close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 1210, in close
super().close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 875, in close
self._loop.call_soon(self._call_connection_lost, None)
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_closed()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
2024-11-22 01:17:49,074 - bespokelabs.curator.request_processor.litellm_online_request_processor - ERROR - Error in request 1: litellm.APIConnectionError: Event loop is closed
Traceback (most recent call last):
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/main.py", line 481, in acompletion
response = await init_response
^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/vertex_ai_and_google_ai_studio/gemini/vertex_and_google_ai_studio_gemini.py", line 1251, in async_completion
response = await client.post(api_base, headers=headers, json=request_body) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 166, in post
raise e
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 123, in post
response = await self.client.send(req, stream=stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1674, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1702, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1776, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 377, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 135, in handle_async_request
await self._response_closed()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 250, in _response_closed
await self.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 258, in aclose
await self._network_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
await self._stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 201, in aclose
await self.transport_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1287, in aclose
self._transport.close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 1210, in close
super().close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 875, in close
self._loop.call_soon(self._call_connection_lost, None)
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_closed()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
2024-11-22 01:17:49,199 - bespokelabs.curator.request_processor.litellm_online_request_processor - ERROR - Error in request 0: litellm.APIConnectionError: Event loop is closed
Traceback (most recent call last):
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/main.py", line 481, in acompletion
response = await init_response
^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/vertex_ai_and_google_ai_studio/gemini/vertex_and_google_ai_studio_gemini.py", line 1251, in async_completion
response = await client.post(api_base, headers=headers, json=request_body) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 166, in post
raise e
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 123, in post
response = await self.client.send(req, stream=stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1674, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1702, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1776, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 377, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 135, in handle_async_request
await self._response_closed()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 250, in _response_closed
await self.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 258, in aclose
await self._network_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
await self._stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 201, in aclose
await self.transport_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1287, in aclose
self._transport.close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 1210, in close
super().close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 875, in close
self._loop.call_soon(self._call_connection_lost, None)
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_closed()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
2024-11-22 01:17:49,321 - bespokelabs.curator.request_processor.litellm_online_request_processor - ERROR - Error in request 1: litellm.APIConnectionError: Event loop is closed
Traceback (most recent call last):
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/main.py", line 481, in acompletion
response = await init_response
^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/vertex_ai_and_google_ai_studio/gemini/vertex_and_google_ai_studio_gemini.py", line 1251, in async_completion
response = await client.post(api_base, headers=headers, json=request_body) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 166, in post
raise e
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 123, in post
response = await self.client.send(req, stream=stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1674, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1702, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1776, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 377, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 135, in handle_async_request
await self._response_closed()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 250, in _response_closed
await self.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 258, in aclose
await self._network_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
await self._stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 201, in aclose
await self.transport_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1287, in aclose
self._transport.close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 1210, in close
super().close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 875, in close
self._loop.call_soon(self._call_connection_lost, None)
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_closed()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
2024-11-22 01:17:49,518 - bespokelabs.curator.request_processor.litellm_online_request_processor - ERROR - Error in request 0: litellm.APIConnectionError: Event loop is closed
Traceback (most recent call last):
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/main.py", line 481, in acompletion
response = await init_response
^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/vertex_ai_and_google_ai_studio/gemini/vertex_and_google_ai_studio_gemini.py", line 1251, in async_completion
response = await client.post(api_base, headers=headers, json=request_body) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 166, in post
raise e
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/litellm/llms/custom_httpx/http_handler.py", line 123, in post
response = await self.client.send(req, stream=stream)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1674, in send
response = await self._send_handling_auth(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1702, in _send_handling_auth
response = await self._send_handling_redirects(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1739, in _send_handling_redirects
response = await self._send_single_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_client.py", line 1776, in _send_single_request
response = await transport.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpx/_transports/default.py", line 377, in handle_async_request
resp = await self._pool.handle_async_request(req)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 256, in handle_async_request
raise exc from None
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection_pool.py", line 236, in handle_async_request
response = await connection.handle_async_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/connection.py", line 103, in handle_async_request
return await self._connection.handle_async_request(request)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 135, in handle_async_request
await self._response_closed()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 250, in _response_closed
await self.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_async/http11.py", line 258, in aclose
await self._network_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/httpcore/_backends/anyio.py", line 53, in aclose
await self._stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/streams/tls.py", line 201, in aclose
await self.transport_stream.aclose()
File "/home/charlieji/.cache/pypoetry/virtualenvs/bespokelabs-curator-809-Lr9v-py3.12/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 1287, in aclose
self._transport.close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 1210, in close
super().close()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/selector_events.py", line 875, in close
self._loop.call_soon(self._call_connection_lost, None)
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 795, in call_soon
self._check_closed()
File "/home/charlieji/miniconda3/lib/python3.12/asyncio/base_events.py", line 541, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True'.
Processing LiteLLM requests: 99%|██████████████████████████████████████████████████████████████████████████████████████▏| 99/100 [00:16<00:00, 5.91it/s]
title ingredients instructions cuisine_type
0 Pan-Fried Pork Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine pork, scallions, soy... Chinese
1 Crispy Pork Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine ground pork, scallio... Chinese
2 Crispy Pork Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine ground pork, scallio... Chinese
3 Crispy Golden Pork Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine pork, scallions, soy... Chinese
4 Stir-Fried Pork with Green Pepper [1 tbsp vegetable oil, 1 lb ground pork, 1/2 c... [Heat vegetable oil in a wok or large skillet ... Chinese
.. ... ... ... ...
95 Crispy Fried Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine ground pork, scallio... Chinese
96 Simple Pork Wontons in Broth [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine ground pork, scallio... Chinese
97 Crispy Fried Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine ground pork, scallio... Chinese
98 Crispy Fried Pork Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine ground pork, scallio... Chinese
99 Golden Pork Wontons [1 lb ground pork, 1/2 cup chopped scallions, ... [In a large bowl, combine the ground pork, sca... Chinese
[100 rows x 4 columns]
(bespokelabs-curator-py3.12) (base) ➜ bella git:(CURATOR-28-add-a-lite-llm-backend-for-curator) ✗
Need to fallback to prompt engineering -> json if the model doesn't have function calling / structured output
Tested on the following models, all working for litellm + instructor structured output
"claude-3-5-sonnet-20240620", # https://docs.litellm.ai/docs/providers/anthropic # anthropic has a different hidden param tokens structure.
"claude-3-5-haiku-20241022",
"claude-3-haiku-20240307",
"claude-3-opus-20240229",
"claude-3-sonnet-20240229",
"gpt-4o-mini", # https://docs.litellm.ai/docs/providers/openai
"gpt-4o-2024-08-06",
"gpt-4-0125-preview",
"gpt-3.5-turbo-1106",
"gemini/gemini-1.5-flash", # https://docs.litellm.ai/docs/providers/gemini; https://ai.google.dev/gemini-api/docs/models # 20-30 iter/s
"gemini/gemini-1.5-pro", # 20-30 iter/s
"together_ai/meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo", # https://docs.together.ai/docs/serverless-models
"together_ai/meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",
"together_ai/mistralai/Mixtral-8x7B-Instruct-v0.1",
Related Issues: #74
Changes:
/examples/litellm_recipe_prompting.py
/examples/litellm_recipe_structured_output.py
(Note: need to put OpenAI and Anthropic keys in environment).backend
parameter when using prompter code link, right now defaults to OpenAI.litellm.completion_cost
, if model cost is in the community-maintained mapping here)estimate_total_tokens
that includesestimate_output_tokens
which derives fromget_max_tokens
that gets max output token of the specified model. code linkx-ratelimit-limit-requests
, andx-ratelimit-limit-tokens
for rpm and tpm.Future Works:
Example
curator-viewer
's view:Tested on the following models, all working for litellm + instructor structured output.
Note that the following models does not support structured output (i.e.
response_format
in Prompter)