import pickle import numpy as np import pandas as pd import nltk from nltk.stem import * nltk.download("punkt_tab") from pathlib import Path import os import google.generativeai as genai import json from google.genai import Client, types BASE_DIR = Path(__file__).resolve().parent.parent FILE_PATH = BASE_DIR / 'ressources' / 'global_tech_embeddings.pkl' def set_prompt(problem): prompt = """ # ROLE You are a meticulous senior technical analyst and constraints scout. Your task is to read a small description of a technical problem and identify distinct constraints each related to the problem and ensuring that the whole problem is encompassed by each constraints into a JSON object. # OBJECTIVE Find all the constraints in this technical problem making sure each are premised on the problem only. Take into account different technical domains to encompass the whole problem. Output each constraints in a JSON such as : {"title of the constraints1":"description1","title of the constraintsN":"descriptionN"} # INSTRUCTIONS & RULES 1. **JSON Output**: Your entire response MUST be a single JSON code block starting with a hyphen (`-`) to denote a list. Do not include any explanatory text before or after the JSON. 2 **Discover and Iterate**: Your primary task is to scan the technical problem, find each constraints and create a seperate entry for it in the output JSON. 3. **Descriptive Sentences**: You MUST write clear, full sentences that describe the constraints's issues. Do not use single keywords. These descriptions should be based on the information in the technical problem. 4. **Infer Where Necessary**: The technical problem may not contain all details. Infer plausible information based on the context. # JSON SCHEMA & EXAMPLE { 'Exposing Compute Resources': 'The 6G network shall provide suitable APIs to allow authorized third parties and/or UEs to retrieve availability information about computational resources inside the Service Hosting Environment (SHE) and to utilize these computational resources for running workloads on demand.', 'Providing AI Compute': 'The 6G network shall be able to provide computing resources in the Service Hosting Environment for AI services and provide AI services to UEs.', ... } --- ***NOW, BEGIN THE TASK.*** # TECHNICAL PROBLEM """ + problem return prompt def load_technologies_excel(): df = pd.read_excel(FILE_PATH) return df def load_technologies(): EMBEDDINGS_FILE = FILE_PATH try: with open(EMBEDDINGS_FILE, 'rb') as f: loaded_data = pickle.load(f) global_tech = loaded_data['global_tech'] global_tech_embedding = loaded_data['global_tech_embeddings'] return global_tech, global_tech_embedding except Exception as e: print(f"Error: {e}") def tech_to_dict(technologies): tech_dict = [] for index, tech in enumerate(technologies): if not tech.find("