-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Implement mcp server, create job tools #1
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| from fastapi import APIRouter | ||
|
|
||
| from app.api.v1 import health | ||
| from app.api.v1 import endpoints | ||
|
|
||
| api_router = APIRouter() | ||
| api_router.include_router(health.router, prefix="/v1", tags=["health"]) | ||
| api_router.include_router(endpoints.router, prefix="/v1", tags=["talentstream"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,162 @@ | ||
| """API v1 endpoints for TalentStreamAI.""" | ||
|
|
||
| from fastapi import APIRouter, HTTPException, UploadFile, File, Form | ||
| from fastapi.responses import JSONResponse | ||
| from pydantic import BaseModel, Field | ||
|
|
||
| from app.services.langgraph import run_talentstream_workflow | ||
| from app.tools.job_fetcher import fetch_job_description | ||
| from app.tools.resume_parser import parse_resume | ||
| from app.tools.ats_scorer import ats_score_resume | ||
|
|
||
| router = APIRouter() | ||
|
|
||
|
|
||
| def validate_resume_file(resume: UploadFile) -> str: | ||
| """Validate resume file format and return the extension.""" | ||
| ext = resume.filename.rsplit(".", 1)[-1].lower() if resume.filename else "" | ||
| if not ext or ext not in ["pdf", "docx", "doc"]: | ||
| raise HTTPException( | ||
| status_code=400, | ||
| detail="Unsupported file format. Use PDF or DOCX.", | ||
| ) | ||
| return ext | ||
|
|
||
|
|
||
| class ApplyRequest(BaseModel): | ||
| job_url: str = Field(..., description="URL of the job posting") | ||
|
|
||
|
|
||
| class ApplyResponse(BaseModel): | ||
| status: str | ||
| job_data: dict | None = None | ||
| resume_data: dict | None = None | ||
| ats_score: dict | None = None | ||
| gap_analysis: dict | None = None | ||
| tailored_resume: str | None = None | ||
| cover_letter: str | None = None | ||
| email_draft: str | None = None | ||
|
|
||
|
|
||
| class FetchJobResponse(BaseModel): | ||
| status: str | ||
| job_data: dict | ||
|
|
||
|
|
||
| class ParseResumeResponse(BaseModel): | ||
| status: str | ||
| resume_data: dict | ||
|
|
||
|
|
||
| class ScoreATSRequest(BaseModel): | ||
| job_url: str = Field(..., description="URL of the job posting") | ||
|
|
||
|
|
||
| class ScoreATSResponse(BaseModel): | ||
| status: str | ||
| ats_score: dict | ||
|
|
||
|
|
||
| @router.post("/apply", response_model=ApplyResponse) | ||
| async def apply_to_job( | ||
| job_url: str = Form(..., description="URL of the job posting"), | ||
| resume: UploadFile = File(..., description="Resume file (PDF or DOCX)"), | ||
| ) -> ApplyResponse: | ||
| """Run complete TalentStreamAI workflow to generate application materials.""" | ||
| import base64 | ||
|
|
||
| ext = validate_resume_file(resume) | ||
|
|
||
| file_content = await resume.read() | ||
| file_b64 = base64.b64encode(file_content).decode("utf-8") | ||
|
|
||
| try: | ||
| result = await run_talentstream_workflow( | ||
| job_url=job_url, | ||
| resume_file=file_b64, | ||
| resume_ext=ext, | ||
| ) | ||
| except ValueError as e: | ||
| raise HTTPException(status_code=500, detail=str(e)) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=f"Workflow failed: {str(e)}") | ||
|
|
||
| if result.get("error"): | ||
| raise HTTPException(status_code=500, detail=result["error"]) | ||
|
|
||
| return ApplyResponse( | ||
| status="success", | ||
| job_data=result.get("job_data"), | ||
| resume_data=result.get("resume_data"), | ||
| ats_score=result.get("ats_score"), | ||
| gap_analysis=result.get("gap_analysis"), | ||
| tailored_resume=result.get("tailored_resume"), | ||
| cover_letter=result.get("cover_letter"), | ||
| email_draft=result.get("email_draft"), | ||
| ) | ||
|
|
||
|
|
||
| @router.post("/fetch-job", response_model=FetchJobResponse) | ||
| async def fetch_job(job_url: str = Form(...)) -> FetchJobResponse: | ||
| """Fetch and parse a job description from URL.""" | ||
| try: | ||
| result = fetch_job_description.invoke({"url": job_url}) | ||
| return FetchJobResponse(status="success", job_data=result) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=f"Failed to fetch job: {str(e)}") | ||
|
|
||
|
|
||
| @router.post("/parse-resume", response_model=ParseResumeResponse) | ||
| async def parse_resume_endpoint( | ||
| resume: UploadFile = File(...), | ||
| ) -> ParseResumeResponse: | ||
| """Parse a resume file (PDF or DOCX).""" | ||
| import base64 | ||
|
|
||
| ext = validate_resume_file(resume) | ||
|
|
||
| file_content = await resume.read() | ||
| file_b64 = base64.b64encode(file_content).decode("utf-8") | ||
|
|
||
| try: | ||
| result = parse_resume.invoke( | ||
| { | ||
| "file_content": file_b64, | ||
| "file_extension": ext, | ||
| } | ||
| ) | ||
| return ParseResumeResponse(status="success", resume_data=result) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=f"Failed to parse resume: {str(e)}") | ||
|
|
||
|
|
||
| @router.post("/score-ats", response_model=ScoreATSResponse) | ||
| async def score_ats( | ||
| job_url: str = Form(...), | ||
| resume: UploadFile = File(...), | ||
| ) -> ScoreATSResponse: | ||
| """Score resume against job description for ATS compatibility.""" | ||
| import base64 | ||
|
|
||
| ext = validate_resume_file(resume) | ||
|
|
||
| file_content = await resume.read() | ||
| file_b64 = base64.b64encode(file_content).decode("utf-8") | ||
|
|
||
| try: | ||
| job_data = fetch_job_description.invoke({"url": job_url}) | ||
| resume_data = parse_resume.invoke( | ||
| { | ||
| "file_content": file_b64, | ||
| "file_extension": ext, | ||
| } | ||
| ) | ||
| score = ats_score_resume.invoke( | ||
| { | ||
| "resume_data": resume_data, | ||
| "job_data": job_data, | ||
| } | ||
| ) | ||
| return ScoreATSResponse(status="success", ats_score=score) | ||
| except Exception as e: | ||
| raise HTTPException(status_code=500, detail=f"Failed to score: {str(e)}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| """MCP server module for TalentStreamAI.""" | ||
|
|
||
| from app.mcp.server import mcp_server | ||
|
|
||
| __all__ = ["mcp_server"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.