File size: 1,595 Bytes
c01955c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import fastapi
from typing import List
from fastapi import Query
from src.Agents.pipelines.DummyInterviews_pipeline import DummyInterviewsPipeline
from src.Agents.pipelines.AiInterviewChat_pipeline import ChatInterviewerPipeline
from src.Agents.constants import DEFAULT_INTERVIEW_FIELDS, DEFAULT_COMPANIES
import logging
import sys
from exception import MyException

router = fastapi.APIRouter()

@router.post("/generate_interview_schemas")
async def generate_interview_schemas(
    no_of_interviews: int = 3,
    updated: bool = False,
    fields: List[str] = Query(default=DEFAULT_INTERVIEW_FIELDS),
    companiesName: List[str] = Query(default=DEFAULT_COMPANIES)
):
    logging.info("Entering generate_interview_schemas route (async)")
    try:
        pipeline = DummyInterviewsPipeline(
            no_of_interviews=no_of_interviews, 
            updated=updated, 
            fields=fields, 
            companiesName=companiesName
        )
        return await pipeline.initiate()
    except Exception as e:
        raise MyException(e, sys)

@router.post("/chat_interviewer")
async def chat_interviewer(
    thread_id: str = '1', 
    time_remain: int = 1, 
    topic: str = 'machine learning', 
    user_input: str = 'hello'
):
    logging.info("Entering chat_interviewer route (async)")
    try:
        pipeline = ChatInterviewerPipeline()
        return await pipeline.initiate(
            thread_id=thread_id, 
            time_remain=time_remain, 
            topic=topic, 
            user_input=user_input
        )
    except Exception as e:
        raise MyException(e, sys)