Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 41 additions & 20 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import pandas as pd

Check warning on line 1 in app.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

app.py#L1

Unused pandas imported as pd
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove unused import.

The pandas import is not used anywhere in the file and should be removed to clean up the codebase.

-import pandas as pd
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import pandas as pd
// (The import `pandas as pd` has been removed; no further changes needed here.)
🧰 Tools
🪛 Ruff (0.11.9)

1-1: pandas imported but unused

Remove unused import: pandas

(F401)

🪛 GitHub Check: Codacy Static Code Analysis

[warning] 1-1: app.py#L1
Unused pandas imported as pd

🤖 Prompt for AI Agents
In app.py at line 1, the pandas import is unused and should be removed to clean
up the code. Delete the line importing pandas from the file.

import chainlit as cl

from src.verifact_manager import VerifactManager

pipeline = VerifactManager()

def get_verdict_value(verdict_text):
match verdict_text:
case "true":
return "✅ True"
case "partially true":
return "🤔 Partially True"
case "false":
return "❌ False"
case _:
return "✖️ Uncertain"

@cl.on_message
async def handle_message(message: cl.Message):
progress_msg = cl.Message(content="Starting fact-checking pipeline...")
progress_msg = cl.Message(content="Starting fact-checking pipeline:")
await progress_msg.send()
progress_updates = []

async def progress_callback(msg, update):
progress_updates.append(update)
msg.content = "\n".join(progress_updates)
msg.content = "\n \u2014".join(progress_updates)
await msg.update()

try:
Expand All @@ -30,28 +42,37 @@
explanation = getattr(verdict, 'explanation', 'N/A')
sources = getattr(verdict, 'sources', [])
sources_str = "\n".join(sources) if sources else "No sources provided."
# Evidence formatting
if evidence:
evidence_str = "\n".join([
f"- {getattr(ev, 'content', str(ev))} (Source: {getattr(ev, 'source', 'N/A')}, Stance: {getattr(ev, 'stance', 'N/A')}, Relevance: {getattr(ev, 'relevance', 'N/A')})"
for ev in evidence
])
else:
evidence_str = "No evidence found."
response += (
f"\n---\n**Claim {idx+1}:** {claim_text}\n"
f"**Evidence:**\n{evidence_str}\n"
f"\n**Verdict:** {verdict_text}\n"
f"**Confidence:** {confidence}\n"
f"**Explanation:** {explanation}\n"
f"**Sources:**\n{sources_str}\n"
)
progress_msg.content = response


claim_title = f"Claim {idx+1}: {claim_text} \u2014 Verdict: {get_verdict_value(verdict_text)}"

async with cl.Step(name=claim_title, type="system") as step:
# Evidence formatting
if evidence:
evidence_str = "\n".join([
f"- {getattr(ev, 'content', str(ev))} (Source: {getattr(ev, 'source', 'N/A')}, Stance: {getattr(ev, 'stance', 'N/A')}, Relevance: {getattr(ev, 'relevance', 'N/A')})"
for ev in evidence
])
else:
evidence_str = "No evidence found."

step.output = (
f"\n---\n**Claim {idx+1}:** {claim_text}\n"
f"**Evidence:**\n{evidence_str}\n"
f"\n**Verdict:** {verdict_text}\n"
f"**Confidence:** {confidence}\n"
f"**Explanation:** {explanation}\n"
f"**Sources:**\n{sources_str}\n"
)
await step.update()

progress_msg.content = ""
await progress_msg.update()

except Exception as e:
progress_msg.content = f"An error occurred during fact-checking: {str(e)}"
await progress_msg.update()

@cl.on_chat_start
async def on_chat_start():
await cl.Message(content="👋 Welcome to VeriFact! The system is up and running. Type your claim or question to get started.").send()
await cl.Message(content="👋 Welcome to VeriFact! The system is up and running. Type your claim or question to get started.").send()