Closed davidbzyk closed 8 months ago
You probably need to define it. Try this modified snippet from the notebook tutorial
from llmx.generators.text.openai_textgen import OpenAITextGenerator
text_gen = OpenAITextGenerator(
api_key=os.environ["OPENAI_API_KEY"],
provider=provider,
models=models
)
lida = Manager(text_gen=text_gen)
Hi @davidbzyk
How did you install lida or llmx (e.g., from source or from pypi ie pip install)?
Ideally, a pip install lida
should be a stable api where all dependencies are installed correctly.
-V
Thanks it actually works fine in vscode notebook but for some reason not in a colab. Appreciate you guys looking into it. Best, Dave
This doesn't seem to be resolved yet. Like @davidbzyk, it works outside of Colab.
The problem within Colab seems to be related to the llxm
package file textgen.py
, where the following lines are commented out in the installed package even if explicitly installing the latest llxm
package using !pip install llmx==0.0.18a0
within Colab:
...
# from .openai_textgen import OpenAITextGenerator
# from .palm_textgen import PalmTextGenerator
# from .cohere_textgen import CohereTextGenerator
...
I'm not sure if this is something that you can resolve or if an issue within Colab, I tried looking through the llxm
package Git history for that file, and couldn't find a commit where those lines were commented out, so it's a bit puzzling.
Following the instructions: from lida import Manager, TextGenerationConfig , llm
lida = Manager(text_gen = llm("openai", api_key=OPENAI_API_KEY)) textgen_config = TextGenerationConfig(n=1, temperature=0.5, model="gpt-4.0", use_cache=True)
NameError Traceback (most recent call last) in <cell line: 1>()
----> 1 lida = Manager(text_gen = llm("openai", api_key=OPENAI_API_KEY))
2 textgen_config = TextGenerationConfig(n=1, temperature=0.5, model="gpt-3.5-turbo-0301", use_cache=True)
/usr/local/lib/python3.10/dist-packages/llmx/generators/text/textgen.py in llm(provider, kwargs) 50 51 if provider.lower() == "openai": ---> 52 return OpenAITextGenerator(kwargs) 53 elif provider.lower() == "palm": 54 return PalmTextGenerator(**kwargs)
NameError: name 'OpenAITextGenerator' is not defined