From 2e3f74d8dd9daf766ff368f034a8e142b600d13f Mon Sep 17 00:00:00 2001 From: Cristiano Hoshikawa Date: Sat, 10 Jan 2026 07:50:18 -0300 Subject: [PATCH] adjust --- .DS_Store | Bin 0 -> 6148 bytes .idea/codeStyles/Project.xml | 7 +++ .idea/codeStyles/codeStyleConfig.xml | 5 +++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 ++++ .idea/rfp_response_automation.iml | 9 ++++ .idea/vcs.xml | 6 +++ .oca/custom_code_review_guidelines.txt | 24 ++++++++++ files/graphrag_rerank.py | 59 +++++++++++++++++++------ 9 files changed, 110 insertions(+), 14 deletions(-) create mode 100644 .DS_Store create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/rfp_response_automation.iml create mode 100644 .idea/vcs.xml create mode 100644 .oca/custom_code_review_guidelines.txt diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..154b1dea0b56a0bebf521d7761b0544679974fda GIT binary patch literal 6148 zcmeHKJxc>Y5S>jTL~K%|5EMBpu@O^?aE22L%lrXNPGcb90-F9xOYs*dR#qwe2^JPM z{)F`Q+F1BzXGwO=X(=Kzu>1Dr;~w+wxV{cmB<+6IhOc@%z8}9`KJA6^^vC${ z%zHQ1CMcx^@b)OB6FLr7NoKMpWr2QYS+3&I04QVNt( z11L-omBx + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..89ee753 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8ccf390 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rfp_response_automation.iml b/.idea/rfp_response_automation.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/rfp_response_automation.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.oca/custom_code_review_guidelines.txt b/.oca/custom_code_review_guidelines.txt new file mode 100644 index 0000000..a0a3b63 --- /dev/null +++ b/.oca/custom_code_review_guidelines.txt @@ -0,0 +1,24 @@ +# Sample guideline, please follow similar structure for guideline with code samples +# 1. Suggest using streams instead of simple loops for better readability. +# +# *Comment: +# Category: Minor +# Issue: Use streams instead of a loop for better readability. +# Code Block: +# +# ```java +# // Calculate squares of numbers +# List squares = new ArrayList<>(); +# for (int number : numbers) { +# squares.add(number * number); +# } +# ``` +# Recommendation: +# +# ```java +# // Calculate squares of numbers +# List squares = Arrays.stream(numbers) +# .map(n -> n * n) // Map each number to its square +# .toList(); +# ``` +# diff --git a/files/graphrag_rerank.py b/files/graphrag_rerank.py index fd144e8..3730bec 100644 --- a/files/graphrag_rerank.py +++ b/files/graphrag_rerank.py @@ -52,6 +52,14 @@ llm_for_rag = ChatOCIGenAI( auth_profile="DEFAULT", ) + +embeddings = OCIGenAIEmbeddings( + model_id="cohere.embed-multilingual-v3.0", + service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com", + compartment_id="ocid1.compartment.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + auth_profile="DEFAULT", +) + oracle_conn = oracledb.connect( user=USERNAME, password=PASSWORD, @@ -170,13 +178,6 @@ ensure_oracle_text_index( "IDX_REL_" + GRAPH_NAME + "_RELTYPE" ) -embeddings = OCIGenAIEmbeddings( - model_id="cohere.embed-multilingual-v3.0", - service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com", - compartment_id="ocid1.compartment.oc1..aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", - auth_profile="DEFAULT", -) - def create_knowledge_graph(chunks): cursor = oracle_conn.cursor() @@ -218,19 +219,19 @@ def create_knowledge_graph(chunks): prompt = f""" You are extracting structured RFP evidence from technical documentation. - + Given the text below, identify ONLY explicit, verifiable facts. - + Text: {text} - + Extract triples in ONE of the following formats ONLY: - + 1. REQUIREMENT -[HAS_SUBJECT]-> 2. REQUIREMENT -[HAS_METRIC]-> 3. REQUIREMENT -[HAS_VALUE]-> 4. REQUIREMENT -[SUPPORTED_BY]-> - + Rules: - Use REQUIREMENT as the source entity - Use UPPERCASE relation names @@ -536,6 +537,8 @@ def save_indexed_docs(docs): # Main Function # ========================= def chat(): + pdf_paths = ['RFP - Financial v2.pdf'] + already_indexed_docs = load_previously_indexed_docs() updated_docs = set() @@ -604,7 +607,7 @@ def chat(): retriever = vectorstore.as_retriever(search_type="similarity", search_kwargs={"k": 50, "fetch_k": 100}) RFP_DECISION_TEMPLATE = """ - You are answering an RFP. + You are answering an RFP requirement with risk awareness. Requirement: Type: {requirement_type} @@ -623,6 +626,17 @@ def chat(): - If value differs, answer PARTIAL - If not found, answer NO + Confidence rules: + - HIGH: Explicit evidence directly answers the requirement + - MEDIUM: Evidence partially matches or requires light interpretation + - LOW: Requirement is ambiguous OR evidence is indirect OR missing + + Ambiguity rules: + - ambiguity_detected = true if: + - The requirement can be interpreted in more than one way + - Keywords are vague (e.g. "support", "integration", "capability") + - Evidence does not clearly bind to subject + expected value + OUTPUT CONSTRAINTS (MANDATORY): - Return ONLY a valid JSON object - Do NOT include explanations, comments, markdown, lists, or code fences @@ -632,6 +646,9 @@ def chat(): JSON schema (return exactly this structure): {{ "answer": "YES | NO | PARTIAL", + "confidence": "HIGH | MEDIUM | LOW", + "ambiguity_detected": true, + "confidence_reason": "", "justification": "", "evidence": [ {{ @@ -756,7 +773,7 @@ except: print("No Faiss") RFP_DECISION_TEMPLATE = """ -You are answering an RFP. +You are answering an RFP requirement with risk awareness. Requirement: Type: {requirement_type} @@ -775,6 +792,17 @@ Decision rules: - If value differs, answer PARTIAL - If not found, answer NO +Confidence rules: +- HIGH: Explicit evidence directly answers the requirement +- MEDIUM: Evidence partially matches or requires light interpretation +- LOW: Requirement is ambiguous OR evidence is indirect OR missing + +Ambiguity rules: +- ambiguity_detected = true if: + - The requirement can be interpreted in more than one way + - Keywords are vague (e.g. "support", "integration", "capability") + - Evidence does not clearly bind to subject + expected value + OUTPUT CONSTRAINTS (MANDATORY): - Return ONLY a valid JSON object - Do NOT include explanations, comments, markdown, lists, or code fences @@ -784,6 +812,9 @@ OUTPUT CONSTRAINTS (MANDATORY): JSON schema (return exactly this structure): {{ "answer": "YES | NO | PARTIAL", + "confidence": "HIGH | MEDIUM | LOW", + "ambiguity_detected": true, + "confidence_reason": "", "justification": "", "evidence": [ {{