-
-
Notifications
You must be signed in to change notification settings - Fork 76
Feature: Generate Opposite Perspective Node #103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ def judge_perspective(state): | |
| if not perspective: | ||
| raise ValueError("Missing or empty 'perspective' in state") | ||
|
|
||
| score = 85 if "reasoned" in perspective else 40 | ||
| score = 85 if "reasoning" in perspective else 40 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace dummy scoring with proper evaluation logic. The current scoring mechanism based on keyword presence ("reasoning") is overly simplistic and fragile. Consider implementing a more robust evaluation system that assesses the quality, coherence, and logical structure of the perspective. - score = 85 if "reasoning" in perspective else 40
+ # TODO: Implement proper perspective evaluation logic
+ # Consider factors like: logical coherence, factual accuracy,
+ # argument structure, and counter-perspective quality
+ score = self._evaluate_perspective_quality(perspective, state.get("facts", []))
🤖 Prompt for AI Agents |
||
| except Exception as e: | ||
| print(f"some error occured in judge_perspetive:{e}") | ||
| return { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,12 +1,13 @@ | ||||||||||||||||||||
| from utils.vector_store import save_to_vector_db | ||||||||||||||||||||
| # from app.utils.vector_store import save_to_vector_db | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| def store_and_send(state): | ||||||||||||||||||||
| # to store data in vector db | ||||||||||||||||||||
| try: | ||||||||||||||||||||
| save_to_vector_db({ | ||||||||||||||||||||
| **state | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| print(state) | ||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Replace print with proper logging. Using print statements for debugging in production code is not recommended. Use the logging module instead. +import logging
- print(state)
+ logging.info(f"Processing state: {state}")📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
| # save_to_vector_db({ | ||||||||||||||||||||
| # **state | ||||||||||||||||||||
| # }) | ||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||
| print(f"some error occured in store_and_send:{e}") | ||||||||||||||||||||
| return { | ||||||||||||||||||||
|
|
||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| from langchain.prompts import ChatPromptTemplate | ||
|
|
||
| generation_prompt = ChatPromptTemplate.from_template(""" | ||
| You are an AI assistant that generates a well-reasoned ' | ||
| 'counter-perspective to a given article. | ||
|
|
||
| ## Article: | ||
| {cleaned_article} | ||
|
|
||
| ## Sentiment: | ||
| {sentiment} | ||
|
|
||
| ## Verified Facts: | ||
| {facts} | ||
|
|
||
| --- | ||
|
|
||
| Generate a logical and respectful *opposite perspective* to the article. | ||
| Use *step-by-step reasoning* and return your output in this JSON format: | ||
|
|
||
| ```json | ||
| {{ | ||
| "counter_perspective": "<your opposite point of view>", | ||
| "reasoning_steps": [ | ||
| "<step 1>", | ||
| "<step 2>", | ||
| "<step 3>", | ||
| "...", | ||
| "<final reasoning>" | ||
| ] | ||
| }} | ||
| """) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix critical string formatting bug in facts_str.
The string formatting is using positional placeholders
{}but accessing dictionary keys directly, which will cause a KeyError.📝 Committable suggestion
🤖 Prompt for AI Agents