forked from phidatahq/phidata
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prompt human for what they want to know about and research the topic and provide analysis
- Loading branch information
Showing
4 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
Query: Information about Ukraine and spending | ||
|
||
Analysis: | ||
|
||
Running: | ||
- transfer_task_to_modern_congress_analyst(task_description=..., expected_output=...) | ||
- transfer_task_to_constitutional_perspective_analyst(task_description=..., expected_output=...) | ||
|
||
### Modern Summary of Legislation Related to Ukraine | ||
|
||
1. **H.R. 8035 - Ukraine Security Supplemental Appropriations Act, 2024**: | ||
- Allocates emergency spending exempt from discretionary limits to support Ukraine's defense efforts. | ||
|
||
2. **Supplemental Security Bill**: | ||
- Signed by President Biden, this extensive bill includes roughly $95 billion, with over $60 billion earmarked for Ukraine. It focuses on military support to counter Russian aggression, including air defense systems, artillery, and armored vehicles. | ||
|
||
These legislations indicate significant financial commitments from the U.S. to Ukraine, reflecting broader geopolitical strategies and alliances. | ||
|
||
### Founding Fathers' Constitutional Perspective | ||
|
||
1. **Constitutional Basis**: | ||
- **Article I, Section 8**: Grants Congress the power to fund activities supporting general welfare and national defense, indirectly authorizing foreign aid. | ||
- **Article I, Section 9**: Stipulates that spending requires Congressional approval. | ||
- **Article II, Section 2**: Specifies presidential powers in treaty-making and foreign relations, emphasizing separation of powers. | ||
|
||
2. **Founders' Views**: | ||
- **Federalist Papers**: Highlight the need for unity and defense against foreign threats. | ||
- **General Welfare Clause**: Provides Congress with flexibility to promote national interests, potentially covering foreign aid. | ||
|
||
3. **Concerns**: | ||
- Emphasis on checks and balances, ensuring legislative oversight of financial allocations. | ||
- Caution against continuous foreign financial commitments to avoid entangling alliances. | ||
|
||
### Contrasts and Interpretations | ||
|
||
- **Constitutional Alignment**: The modern decision to allocate funds to Ukraine aligns with constitutional provisions, though the scale and form of such aid extend beyond the foresight of the founders. | ||
|
||
- **Founders' Intent and Modern Actions**: While the founding fathers might not have envisioned direct foreign aid as practiced today, the constitutional framework allows for adapting to new international contexts by leveraging Congressional powers. | ||
|
||
- **Cautions**: The founders' wariness of entangling alliances suggests that while aid is constitutionally viable, the permanence and extent of such commitments should be carefully evaluated to maintain sovereignty and national interests. | ||
|
||
In summary, the constitutional mechanisms established by the founding fathers give Congress the authority to engage in foreign aid, endorsing flexibility to navigate contemporary geopolitical realities while stressing the importance of checks and balances. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from historical_agent import ( | ||
congress_analyst, | ||
founding_father_analyst, | ||
congress_analysis_team, | ||
load_knowledge_bases | ||
) | ||
from pathlib import Path | ||
|
||
def interactive_analysis(): | ||
"""Interactive CLI for natural language congressional analysis""" | ||
print("\nWelcome to the Congressional Analysis System") | ||
print("------------------------------------------") | ||
print("Ask any question about Congress, bills, or constitutional implications.") | ||
print("Examples:") | ||
print("- What are the recent gun control bills and their constitutional implications?") | ||
print("- Analyze healthcare legislation from 2023") | ||
print("- What would the founding fathers think about H.R. 1234?") | ||
print("- Compare recent privacy laws with constitutional principles") | ||
|
||
# Ensure knowledge bases are loaded | ||
load_knowledge_bases(force_reload=False) | ||
|
||
# Create analyses directory if it doesn't exist | ||
analyses_dir = Path("democracy/analyses") | ||
analyses_dir.mkdir(exist_ok=True, parents=True) | ||
|
||
while True: | ||
# Get natural language query from user | ||
query = input("\nWhat would you like to know? (or 'exit' to quit): ") | ||
|
||
if query.lower() == 'exit': | ||
print("\nThank you for using the Congressional Analysis System.") | ||
break | ||
|
||
try: | ||
# Let the LLM handle query interpretation and analysis | ||
analysis = congress_analysis_team.run(f""" | ||
Analyze the following query about congressional legislation | ||
and provide both modern and historical constitutional perspectives: | ||
{query} | ||
Consider: | ||
- Relevant bills and their status | ||
- Constitutional implications | ||
- Historical context | ||
- Current impact | ||
""") | ||
|
||
print("\nAnalysis Results:") | ||
print("----------------") | ||
print(analysis.content) | ||
|
||
# Option to save | ||
save = input("\nWould you like to save this analysis? (y/n): ") | ||
if save.lower() == 'y': | ||
filename = input("Enter filename to save as: ") | ||
with open(analyses_dir / f"{filename}.txt", "w") as f: | ||
f.write(f"Query: {query}\n\nAnalysis:\n{analysis.content}") | ||
print(f"Analysis saved to analyses/{filename}.txt") | ||
|
||
except Exception as e: | ||
print(f"\nError processing query: {str(e)}") | ||
print("Please try rephrasing your question.") | ||
|
||
if __name__ == "__main__": | ||
interactive_analysis() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from phi.knowledge.combined import CombinedKnowledgeBase | ||
from phi.vectordb.pgvector import PgVector | ||
|
||
class TopicKnowledgeBase: | ||
def __init__(self, topic: str, db_url: str): | ||
self.topic = topic | ||
self.db_url = db_url | ||
|
||
def build_topic_query(self) -> str: | ||
"""Build API query for specific topic""" | ||
base_query = { | ||
"gun laws": [ | ||
"firearm", "weapon", "second amendment", | ||
"gun control", "gun rights" | ||
], | ||
"healthcare": [ | ||
"health", "medical", "insurance", | ||
"medicare", "medicaid" | ||
], | ||
# Add more topic mappings | ||
} | ||
|
||
return " OR ".join(base_query.get(self.topic.lower(), [self.topic])) |