Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: asdict() should be called on dataclass instances #96

Open
Mukkkki opened this issue Feb 8, 2024 · 1 comment
Open

TypeError: asdict() should be called on dataclass instances #96

Mukkkki opened this issue Feb 8, 2024 · 1 comment

Comments

@Mukkkki
Copy link

Mukkkki commented Feb 8, 2024

When trying to execute the code
goals = lida.goals(summary, n=2, textgen_config=text_gen)
for goal_dict in goals:
for key, value in goal_dict.items():
print(f"{key}: {value}")

<llmx.generators.text.hf_textgen.HFTextGenerator object at 0x7f3c894ba680>


TypeError Traceback (most recent call last)
Cell In[3], line 1
----> 1 goals = lida.goals(summary, n=2, textgen_config=text_gen)
2 for goal_dict in goals:
3 for key, value in goal_dict.items():

File ~/venv/lib/python3.10/site-packages/lida/components/manager.py:177, in Manager.goals(self, summary, textgen_config, n, persona)
174 if isinstance(persona, str):
175 persona = Persona(persona=persona, rationale="")
--> 177 return self.goal.generate(summary=summary, text_gen=self.text_gen,
178 textgen_config=textgen_config, n=n, persona=persona)

File ~/venv/lib/python3.10/site-packages/lida/components/goal.py:51, in GoalExplorer.generate(self, summary, textgen_config, text_gen, n, persona)
43 user_prompt += f"""\n The generated goals SHOULD BE FOCUSED ON THE INTERESTS AND PERSPECTIVE of a '{persona.persona} persona, who is insterested in complex, insightful goals about the data. \n"""
45 messages = [
46 {"role": "system", "content": SYSTEM_INSTRUCTIONS},
47 {"role": "assistant",
48 "content":
49 f"{user_prompt}\n\n {FORMAT_INSTRUCTIONS} \n\n. The generated {n} goals are: \n "}]
---> 51 result: list[Goal] = text_gen.generate(messages=messages, config=textgen_config)
53 try:
54 json_string = clean_code_snippet(result.text[0]["content"])

File ~/venv/lib/python3.10/site-packages/llmx/generators/text/hf_textgen.py:171, in HFTextGenerator.generate(self, messages, config, **kwargs)
168 config.model = self.model_name
169 print(config)
170 cache_key_params = {
--> 171 **asdict(config),
172 **kwargs,
173 "messages": messages,
174 "dialogue_type": self.dialogue_type}
175 if use_cache:
176 response = cache_request(cache=self.cache, params=(cache_key_params))

File /usr/lib/python3.10/dataclasses.py:1237, in asdict(obj, dict_factory)
1218 """Return the fields of a dataclass instance as a new dictionary mapping
1219 field names to field values.
1220
(...)
1234 tuples, lists, and dicts.
1235 """
1236 if not _is_dataclass_instance(obj):
-> 1237 raise TypeError("asdict() should be called on dataclass instances")
1238 return _asdict_inner(obj, dict_factory)

TypeError: asdict() should be called on dataclass instances

@Mukkkki
Copy link
Author

Mukkkki commented Feb 8, 2024

goals = lida.goals(summary, n=2, textgen_config=text_gen)

for goal in goals:
display(goal)

This all give the same above error , any idea how to resolve this issues , using hugging face model which was shown as dummy example in tutorial notebook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant