Spaces:
Sleeping
Sleeping
Download utils/question_route.py from Samagra07/LinkedIn-Post-Generator: direct link, hf CLI and curl.
- Browser
- Download file 801 Bytes
-
https://huggingface.co/spaces/Samagra07/LinkedIn-Post-Generator/resolve/main/utils/question_route.py
- Command line
-
hf download hf://spaces/Samagra07/LinkedIn-Post-Generator/utils/question_route.py
-
curl -L -o question_route.py https://huggingface.co/spaces/Samagra07/LinkedIn-Post-Generator/resolve/main/utils/question_route.py
801 Bytes
| from loggers.logger import logger | |
| from template.router_prompt import QUESTION_ROUTER | |
| import sys | |
| sys.dont_write_bytecode = True | |
| query_router = QUESTION_ROUTER | |
| def route_question(state): | |
| """ | |
| Route question to web search or generation. | |
| Args: | |
| state (dict): The current graph state | |
| Returns: | |
| str: Next node to call | |
| """ | |
| logger.info("INSIDE ROUTE QUESTION FUNCTION") | |
| question = state['question'] | |
| output = query_router.invoke( | |
| { | |
| "question": question | |
| } | |
| ) | |
| if output['choice'] == "web_search": | |
| logger.info("ROUTING QUERY TO WEB SEARCH CONTENT") | |
| return "websearch" | |
| elif output['choice'] == "generate": | |
| logger.info("ROUTING QUERY TO GENERATION CONTENT") | |
| return "generate" | |