Credit-Card-Recommender-Knowledge-graph-implementation / intent_classification /fd_classification.py
Download intent_classification/fd_classification.py from Sulaiman8/Credit-Card-Recommender-Knowledge-graph-implementation: direct link, hf CLI and curl.
- Browser
- Download file 988 Bytes
-
https://huggingface.co/spaces/Sulaiman8/Credit-Card-Recommender-Knowledge-graph-implementation/resolve/main/intent_classification/fd_classification.py
- Command line
-
hf download hf://spaces/Sulaiman8/Credit-Card-Recommender-Knowledge-graph-implementation/intent_classification/fd_classification.py
-
curl -L -o fd_classification.py https://huggingface.co/spaces/Sulaiman8/Credit-Card-Recommender-Knowledge-graph-implementation/resolve/main/intent_classification/fd_classification.py
988 Bytes
| import google.generativeai as genai | |
| import os | |
| #for intent classification | |
| def find_intent(user_query: str) -> bool: | |
| genai.configure(api_key=os.environ.get("api_key_2")) | |
| model2 = genai.GenerativeModel('gemini-2.0-flash') | |
| prompt = f""" | |
| You are a helpful assistant. A user has asked the following question or made the following request: | |
| "{user_query}" | |
| Determine ONLY whether this query is likely about FD-based (fixed deposit backed) credit cards. | |
| These cards typically do not require a credit score, are suited for users with low income, users who are new to credit cards/beginners, who have no/low credit score or students. | |
| Respond with just "true" or "false" depending on whether the user's query is about such cards. | |
| No explanation, no extra words — just true or false. | |
| """ | |
| response = model2.generate_content(prompt) | |
| result = response.text.strip().lower() | |
| return result == "true" | |