Skip to content

Created necessary methods for Persona CRUD #1232

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

Merged
merged 2 commits into from
Mar 6, 2025
Merged

Conversation

aponcedeleonch
Copy link
Contributor

Closes: #1219

Some changes in this PR

  • Renamed Semantic Router to PersonaManager: The motivation is that the only semantic routing we're doing is based on persona. So lets just call it that wat
  • Created update and delete methods for Persona
  • Added tests for the whole Persona CRUD

Closes: #1219

Some changes in this PR
- Renamed Semantic Router to PersonaManager: The motivation
is that the only semantic routing we're doing is based on persona.
So lets just call it that wat
- Created update and delete methods for Persona
- Added tests for the whole Persona CRUD
Copy link
Contributor

@peppescg peppescg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✈️

@aponcedeleonch aponcedeleonch merged commit 258fc98 into main Mar 6, 2025
11 checks passed
@aponcedeleonch aponcedeleonch deleted the persona-crud branch March 6, 2025 07:29
persona = await dbreader.get_persona_by_name(persona_name)
if not persona:
raise HTTPException(status_code=404, detail=f"Persona {persona_name} not found")
return persona
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we be catching the exception when a persona doesn't exist?

raise HTTPException(status_code=404, detail=f"Persona {persona_name} not found")
return persona
except Exception as e:
if isinstance(e, HTTPException):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the db reader be raising an HTTP exception? This sounds off

async def list_personas() -> List[Persona]:
"""List all personas."""
try:
personas = await dbreader.get_all_personas()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not leverage the persona manager here to keep the code consistent? Adding the dbreader here seems like an antipattern

raise HTTPException(status_code=500, detail="Internal server error")


@v1.get("/personas/{persona_name}", tags=["Personas"], generate_unique_id_function=uniq_name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use an annotated object to do input validation on persona_name? I'd like to restrict the characters that folks can use here to prevent vulnerabilities.

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

Successfully merging this pull request may close these issues.

[Task]: CRUD for Personas
3 participants