Metadata-Version: 2.4
Name: korea-weak-signal
Version: 0.1.0
Summary: Lightweight Python SDK and AI Agent tool for real-time Korean market intelligence signals
Home-page: https://github.com/korea-weak-signal/korea-weak-signal-python
Author: Korea Weak Signal Team
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: requests>=2.25.0
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.1.0; extra == "langchain"
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# korea-weak-signal

[![PyPI version](https://badge.fury.io/py/korea-weak-signal.svg)](https://badge.fury.io/py/korea-weak-signal)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Lightweight Python client library and AI agent tool for fetching real-time Korean market intelligence signals synthesized from public domain anomalies (G2B public procurement tenders, KIPRIS patent filings, and Saramin recruitment surges).

---

## Key Features

- **Real-Time Signal Ingestion**: Access cross-domain market weak signals in Korea (Z-score $\ge 2.5$).
- **AI Agent Native**: Pre-built function wrappers for **LangChain**, **LlamaIndex**, and **AutoGPT** tool calling.
- **Fast & Lightweight**: Zero heavy dependencies; standard client relies only on `requests`.

---

## Installation

Install the package via `pip`:

```bash
pip install korea-weak-signal
```

For LangChain integration support:

```bash
pip install korea-weak-signal[langchain]
```

---

## Quickstart Usage

### 1. Standard Python SDK

```python
from korea_weak_signal import WeakSignalClient

# Initialize client (uses default Cloud Run API endpoint)
client = WeakSignalClient(
    api_key="YOUR_OPTIONAL_RAPIDAPI_KEY"  # Optional if using RapidAPI header
)

# Fetch latest emerging weak signals
response = client.get_emerging_signals()

print(f"Retrieved {response['count']} emerging signals at {response['retrieved_at']}")
for item in response.get("data", []):
    signal = item["signal"]
    print(f"\n[Topic]: {signal['raw_topic']} (Category: {signal['category']})")
    print(f"Confidence Score: {signal['score']}/100")
    print(f"Summary: {signal['summary_en']}")
    print("Recommended Actions:")
    for action in signal.get("recommended_agent_actions", []):
        print(f" - {action}")
```

---

## AI Agent Integration (LangChain / LlamaIndex / AutoGPT)

### 2. LangChain Function Calling Example

You can bind `get_emerging_signals_tool` directly into LangChain agents or OpenAI tool calls:

```python
from korea_weak_signal import get_emerging_signals_tool
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate

# Initialize LLM
llm = ChatOpenAI(model="gpt-4o", temperature=0)

# Bind the weak signal tool
tools = [get_emerging_signals_tool]

prompt = ChatPromptTemplate.from_messages([
    ("system", "You are an AI investment analyst tracking weak market signals in South Korea."),
    ("human", "{input}"),
    ("placeholder", "{agent_scratchpad}"),
])

# Construct Agent
agent = create_tool_calling_agent(llm, tools, prompt)
agent_executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

# Run Query
response = agent_executor.invoke({
    "input": "Check if there are any emerging weak signals in Korea related to hardware or clean energy."
})

print(response["output"])
```

---

## Configuration

| Environment Variable | Description | Default |
| --- | --- | --- |
| `RAPIDAPI_KEY` | RapidAPI header key (`X-RapidAPI-Key`) | `None` |
| `KOREA_WEAK_SIGNAL_API_KEY` | Alternative environment variable for API key | `None` |

---

## License

MIT License. See [LICENSE](LICENSE) for details.
