Skip to content

Commit

Permalink
Handle variables that could be None
Browse files Browse the repository at this point in the history
  • Loading branch information
ramnes committed Jul 26, 2023
1 parent 50da131 commit a870712
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/chainlit/client/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ async def get_conversation(self, conversation_id: str):
where={"id": conversation_id}, include={"messages": True, "elements": True}
)

for m in c.messages:
for m in c.messages or []:
if m.llmSettings:
m.llmSettings = json.loads(m.llmSettings)

for e in c.elements:
for e in c.elements or []:
if e.forIds:
e.forIds = json.loads(e.forIds)

Expand Down
6 changes: 6 additions & 0 deletions src/chainlit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,13 @@ def load_module(target: str):
sys.path.insert(0, target_dir)

spec = util.spec_from_file_location(target, target)
if not spec or not spec.loader:
return

module = util.module_from_spec(spec)
if not module:
return

spec.loader.exec_module(module)

sys.modules[target] = module
Expand Down

0 comments on commit a870712

Please sign in to comment.