-
Notifications
You must be signed in to change notification settings - Fork 78
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
Conversation
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Closes: #1219
Some changes in this PR