-
Notifications
You must be signed in to change notification settings - Fork 7
OpenAI: Adding auth #117
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
OpenAI: Adding auth #117
Conversation
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
| from app.core import settings, logging | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| router = APIRouter(tags=["threads"]) |
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.
from urllib.parse import urlparse
def validate_callback_url(url: str) -> bool:
parsed = urlparse(url)
return bool(parsed.scheme and parsed.netloc)
def send_callback(callback_url: str, data: dict):
if not validate_callback_url(callback_url):
logger.error(f'Invalid callback URL format: {callback_url}')
return FalseThe callback URL is used without validation. Add URL validation to ensure the callback_url is properly formatted and follows security best practices.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
| Returns an immediate "processing" response, then continues to run create_and_poll in background. | ||
| Once completed, calls send_callback with the final result. | ||
| """ | ||
| client = OpenAI(api_key=settings.OPENAI_API_KEY) |
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.
def get_openai_client() -> OpenAI:
return OpenAI(api_key=settings.OPENAI_API_KEY)
@router.post('/threads')
async def threads(
request: dict,
background_tasks: BackgroundTasks,
client: OpenAI = Depends(get_openai_client),
_session: Session = Depends(get_db),
_current_user: UserProjectOrg = Depends(verify_user_project_organization),
):The OpenAI client is created for each request. Consider moving the client initialization to a dependency function to enable better resource management and reuse.
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.
Kody Review CompleteGreat news! 🎉 Keep up the excellent work! 🚀 Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
3b156d9 to
209e38c
Compare
Code Review Completed! 🔥The code review was successfully completed based on your current configurations. Kody Guide: Usage and ConfigurationInteracting with Kody
Current Kody ConfigurationReview OptionsThe following review options are enabled or disabled:
|
Codecov ReportAttention: Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
Target issue is #102
Checklist
Before submitting a pull request, please ensure that you mark these task.
fastapi run --reload app/main.pyordocker compose upin the repository root and test.