Home Artists Posts Import Register

Downloads

Content

Code files are for video: https://youtu.be/eAikW9o1Ros

MAKING PARALLEL CALLS TO THE LLM WILL COST EXTRA TOKENS!!

Async is important because you can run multiple calls to the OpenAI API at the same time instead of one by one. Therefore it results in significant speed gains when you want to make multiple calls at the same time.

Relevant links:
langchain async blog post: https://blog.langchain.dev/async-api/

miniconda: https://docs.conda.io/en/latest/miniconda.html

Python Async walkthrough: https://realpython.com/async-io-python/#setting-up-your-environment

langchain async for llm calls: https://langchain.readthedocs.io/en/latest/modules/llms/async_llm.html

langchain async for chain calls: https://langchain.readthedocs.io/en/latest/modules/chains/async_chain.html

lanchain async for agent calls: https://langchain.readthedocs.io/en/latest/modules/agents/examples/async_agent.html

wikipedia article about Kaprekar's constant: https://en.wikipedia.org/wiki/6174_(number)

Comments

vesper8

Just want to point out that the three readthedocs.io links are now 404s

echohive42

Thanks for letting me know. I will try to find the new ones and update the links

vesper8

Also getting this warning when running llm.py with instructions. Not sure if you'd want to update the scripts. It's still working though UserWarning: You are trying to use a chat model. This way of initializing it is no longer supported. Instead, please use: `from langchain.chat_models import ChatOpenAI`

vesper8

I've tried to replace llm = OpenAIChat(temperature=0.9) with llm = ChatOpenAI(temperature=0.9, model_name="gpt-3.5-turbo", openai_api_key=os.getenv('OPENAI_API_KEY')) After adding from langchain.chat_models import ChatOpenAI I also confirmed my API key is read correctly. But it seems it's not that simple. Now I'm getting File "/opt/homebrew/lib/python3.10/site-packages/langchain/chat_models/base.py", line 119, in agenerate results = await asyncio.gather( File "/opt/homebrew/lib/python3.10/site-packages/langchain/chat_models/openai.py", line 359, in _agenerate message_dicts, params = self._create_message_dicts(messages, stop) File "/opt/homebrew/lib/python3.10/site-packages/langchain/chat_models/openai.py", line 341, in _create_message_dicts message_dicts = [_convert_message_to_dict(m) for m in messages] File "/opt/homebrew/lib/python3.10/site-packages/langchain/chat_models/openai.py", line 341, in message_dicts = [_convert_message_to_dict(m) for m in messages] File "/opt/homebrew/lib/python3.10/site-packages/langchain/chat_models/openai.py", line 117, in _convert_message_to_dict raise ValueError(f"Got unknown type {message}") ValueError: Got unknown type T

echohive42

Thank you for letting me know. I was thinking of going over old projects when I find some time. Maybe I will make live streams while updating the code