Francisco Zanartu commited on
Commit
68d2244
·
1 Parent(s): 124eea0

feat: integrate text classification pipeline for dynamic fallacy detection

Browse files
Files changed (1) hide show
  1. src/api/rebuttal.py +3 -3
src/api/rebuttal.py CHANGED
@@ -2,7 +2,7 @@ import random
2
  from pathlib import Path
3
  from collections import namedtuple
4
  from langchain_core.prompts import PromptTemplate
5
- from pydantic import BaseModel
6
  from ..llm.llms import google_llm_with_search_tool, google_llm
7
 
8
  PROMPT_DIR = Path(__file__).parent.parent / "prompts"
@@ -27,7 +27,7 @@ DEFINITIONS = {
27
  "slothful induction": "Ignoring relevant evidence when coming to a conclusion",
28
  }
29
 
30
-
31
  llm = google_llm
32
  llm_with_search_tool = google_llm_with_search_tool
33
 
@@ -82,7 +82,7 @@ class RebuttalStructure:
82
  summary = summary_chain.invoke({"misinformation": misinformation})
83
 
84
  # pick a random fallacy, definition form DEFINITIONS
85
- fallacy = random.choice(list(DEFINITIONS.keys()))
86
  fallacy_definition = DEFINITIONS[fallacy]
87
 
88
  fallacy_explanation = fallacy_chain.invoke(
 
2
  from pathlib import Path
3
  from collections import namedtuple
4
  from langchain_core.prompts import PromptTemplate
5
+ from transformers import pipeline
6
  from ..llm.llms import google_llm_with_search_tool, google_llm
7
 
8
  PROMPT_DIR = Path(__file__).parent.parent / "prompts"
 
27
  "slothful induction": "Ignoring relevant evidence when coming to a conclusion",
28
  }
29
 
30
+ pipe = pipeline("text-classification", model="fzanartu/flicc")
31
  llm = google_llm
32
  llm_with_search_tool = google_llm_with_search_tool
33
 
 
82
  summary = summary_chain.invoke({"misinformation": misinformation})
83
 
84
  # pick a random fallacy, definition form DEFINITIONS
85
+ fallacy = pipe(misinformation)[0].get("label")
86
  fallacy_definition = DEFINITIONS[fallacy]
87
 
88
  fallacy_explanation = fallacy_chain.invoke(