Skip to content

Commit

Permalink
fix:handle conflicting persona names
Browse files Browse the repository at this point in the history
  • Loading branch information
JarbasAl committed Nov 13, 2024
1 parent e1105c8 commit 96193b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ pip install ovos-persona

### Configuring Personas

Personas are loaded from configuration files, which can either be directly provided by plugins or user-defined JSON files.
Personas are loaded from configuration files, which can either be [directly provided by plugins](https://github.com/OpenVoiceOS/ovos-solver-openai-persona-plugin/pull/12) or user-defined JSON files.

By default, personas are loaded from the XDG configuration directory, just create .json files under `~/.config/ovos_persona`

Personas are mainly defined via [solver plugins](https://openvoiceos.github.io/ovos-technical-manual/solvers/), each plugin is tried by order until one provides an answer
Personas work via [solver plugins](https://openvoiceos.github.io/ovos-technical-manual/solvers/), each plugin is tried by order until one provides an answer

Find solver plugins [here](https://github.com/OpenVoiceOS?q=solver&type=all), some solvers may also use other solvers internally, such as a [MOS (Mixture Of Solvers)](https://github.com/TigreGotico/ovos-MoS)

Expand Down
19 changes: 12 additions & 7 deletions ovos_persona/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,6 @@ def default_persona(self) -> Optional[str]:
def load_personas(self, personas_path: Optional[str] = None):
personas_path = personas_path or get_xdg_config_save_path("ovos_persona")
LOG.info(f"Personas path: {personas_path}")
# load personas provided by packages
for name, persona in find_persona_plugins().items():
if name in self.blacklist:
continue
self.personas[name] = Persona(name, persona)

# load user defined personas
os.makedirs(personas_path, exist_ok=True)
Expand All @@ -133,6 +128,17 @@ def load_personas(self, personas_path: Optional[str] = None):
continue
with open(f"{personas_path}/{p}") as f:
persona = json.load(f)
LOG.info(f"Found persona (user defined): {name}")
self.personas[name] = Persona(name, persona)

# load personas provided by packages
for name, persona in find_persona_plugins().items():
if name in self.blacklist:
continue
if name in self.personas:
LOG.info(f"Ignoring persona (provided via plugin): {name}")
continue
LOG.info(f"Found persona (provided via plugin): {name}")
self.personas[name] = Persona(name, persona)

def register_persona(self, name, persona):
Expand Down Expand Up @@ -306,8 +312,7 @@ def handle_persona_release(self, message):


if __name__ == "__main__":
b = PersonaService(FakeBus(),
config={"personas_path": "/home/miro/PycharmProjects/ovos-persona/personas"})
b = PersonaService(FakeBus())
print(b.personas)

print(b.match_low(["what is the speed of light"]))
Expand Down

0 comments on commit 96193b5

Please sign in to comment.