A lightweight Python package for automatically extracting and summarizing key concepts from complex psychological and political theories.
Given a text excerpt or a summary of a theoretical work, psycopol_synth uses an LLM to identify post‑Freudian psychological ideas, their relationship to political dynamics, and the main arguments, critiques, and potential applications.
- Extracts concepts, relationships, and implications from dense theory texts.
- Works with the free tier of LLM7 out of the box.
- Accepts any LangChain chat model (OpenAI, Anthropic, Google Gemini …).
- Returns a structured list of tokens that match a predefined regex pattern, guaranteeing consistent output for downstream processing.
pip install psycopol_synthfrom psycopol_synth import psycopol_synth
text = """
In his critique of classical political theory, Freud argues that the emotional underpinnings of state ideology are rooted in subconscious desires. Contemporary scholars extend this view by incorporating psychoanalytic frameworks into analyses of political mobilization.
"""
# Using the default LLM7 provider
results = psycopol_synth(user_input=text)
# results is a list of extracted strings following the regex pattern
print(results)psycopol_synth accepts any LangChain chat model.
Below are examples for several popular providers.
from langchain_openai import ChatOpenAI
from psycopol_synth import psycopol_synth
llm = ChatOpenAI() # You can set `model_name`, `temperature`, etc.
response = psycopol_synth(user_input=text, llm=llm)from langchain_anthropic import ChatAnthropic
from psycopol_synth import psycopol_synth
llm = ChatAnthropic()
response = psycopol_synth(user_input=text, llm=llm)from langchain_google_genai import ChatGoogleGenerativeAI
from psycopol_synth import psycopol_synth
llm = ChatGoogleGenerativeAI()
response = psycopol_synth(user_input=text, llm=llm)The default ChatLLM7 instance uses the LLM7_API_KEY environment variable.
If you wish to supply the key directly:
response = psycopol_synth(user_input=text, api_key="your_llm7_api_key")A free key can be obtained by registering at https://token.llm7.io/.
def psycopol_synth(
user_input: str,
api_key: Optional[str] = None,
llm: Optional[BaseChatModel] = None
) -> List[str]| Parameter | Type | Description |
|---|---|---|
user_input |
str |
The raw text or summary that you wish to analyze. |
llm |
Optional[BaseChatModel] |
A LangChain chat model instance. If omitted, the function falls back to ChatLLM7. |
api_key |
Optional[str] |
API key for the LLM7 provider. Ignored if a custom LLM is supplied. |
- The free tier of LLM7 comfortably handles the majority of use cases.
- If you exceed the default limits, simply provide your own
api_keyto increase the quota.
Please report bugs or submit feature requests at
https://github.com/chigwell/psycopol-synth/issues.
- Eugene Evstafev
- Email: hi@euegne.plus
- GitHub: https://github.com/chigwell