semantix
semantix copied to clipboard
UnboundLocalError when running example code
UnboundLocalError when running example code
Description
When running the example code provided in the documentation, an UnboundLocalError occurs, indicating that the variable meaning is referenced before assignment.
Steps to Reproduce
- Use the following code:
from enum import Enum
from dataclasses import dataclass
from semantix import Semantic, enhance
from semantix.llms import OpenAI
import os
os.environ["OPENAI_API_KEY"] = "your-api-key" # Replace with your actual API key
os.environ["OPENAI_API_BASE"] = "your-api-base-url" # Replace with your actual API base URL
llm = OpenAI()
class Personality(Enum):
INTROVERT = "Introvert"
EXTROVERT = "Extrovert"
@dataclass
class Person:
full_name: str
yod: Semantic[int, "Year of Death"]
personality: Semantic[Personality, "Personality of the Person"]
@enhance("Get Person Informations using common knowledge", llm)
def get_person(name: Semantic[str, "Name of the Person"]) -> Person:
...
person_obj = get_person(name="Albert Einstein")
print(f"{person_obj.full_name} is an {person_obj.personality.value} who died in {person_obj.yod}")
- Run the code and encounter the following error:
UnboundLocalError: local variable 'meaning' referenced before assignment
Expected Behavior
The code should execute successfully and output the information about Albert Einstein.
Actual Behavior
The code raises an UnboundLocalError.
Environment
- Python version: 3.10
- semantix library version: [Please specify the version you are using]
- Operating system: [Please specify your operating system]
Additional Context
The error occurs at line 102 of the semantix/decorators.py file:
action = f"{meaning} ({func.__name__})"
This issue might be related to the configuration of the API or an internal bug within the semantix library. Please let me know if you need any further information to diagnose and fix this problem.