Skip to content

psycopol-synth analyzes psychological-political theories, extracting concepts and relationships to provide clear structured summaries.

Notifications You must be signed in to change notification settings

chigwell/psycopol-synth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

psycopol-synth

PyPI version License: MIT Downloads LinkedIn

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.

Features

  • 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.

Installation

pip install psycopol_synth

Quickstart

from 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)

Using a Custom LLM

psycopol_synth accepts any LangChain chat model.
Below are examples for several popular providers.

OpenAI

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)

Anthropic

from langchain_anthropic import ChatAnthropic
from psycopol_synth import psycopol_synth

llm = ChatAnthropic()
response = psycopol_synth(user_input=text, llm=llm)

Google Gemini

from langchain_google_genai import ChatGoogleGenerativeAI
from psycopol_synth import psycopol_synth

llm = ChatGoogleGenerativeAI()
response = psycopol_synth(user_input=text, llm=llm)

Specifying an LLM7 API Key

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/.

Function Signature

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.

Rate Limits & Performance

  • The free tier of LLM7 comfortably handles the majority of use cases.
  • If you exceed the default limits, simply provide your own api_key to increase the quota.

Issues & Support

Please report bugs or submit feature requests at
https://github.com/chigwell/psycopol-synth/issues.

Author