Hi Logan, Thanks for sticking with this. There is clearly something very basic that I am getting wrong here.
I went to the
https://docs.llamaindex.ai/en/stable/api_reference/llms/openai/ docs page and tried to just run the simple example there:
import os
import openai
os.environ["OPENAI_API_KEY"] = "sk-..."
openai.api_key = os.environ["OPENAI_API_KEY"]
from llama_index.llms.openai import OpenAI
llm = OpenAI(model="gpt-3.5-turbo")
stream = llm.stream("Hi, write a short story")
for r in stream:
print(r.delta, end="")
(I confirmed that I can invoke the LLM correctly using a seoparate bit of code - so I know that OpenAi key is working for this selected model).Even this error's out as follows:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[14], line 11
7 from llama_index.llms.openai import OpenAI
9 llm = OpenAI(model="gpt-3.5-turbo")
---> 11 stream = llm.stream("Hi, write a short story")
13 for r in stream:
14 print(r.delta, end="")
//
Cut out for brevity//
File /opt/anaconda3/envs/testllamaindex/lib/python3.11/site-packages/llama_index/core/llms/llm.py:218, in LLM._log_template_data(self, prompt,
prompt_args) 213 def _log_template_data( 214 self, prompt: BasePromptTemplate, prompt_args: Any
215 ) -> None:
216 template_vars = {
217 k: v
--> 218 for k, v in ChainMap(prompt.kwargs, prompt_args).items()
219 if k in prompt.template_vars
220 }
221 with self.callback_manager.event(
222 CBEventType.TEMPLATING,
223 payload={
(...)
228 },
229 ):
230 pass
AttributeError: 'str' object has no attribute 'kwargs'