Skip to content

Add LangChain integration example #4

@base76-research-lab

Description

@base76-research-lab

Context

LangChain is the most widely used LLM framework. Many users will want to plug NoUse into an existing LangChain chain or agent.

Task

Create `examples/langchain_example.py` showing how to use NoUse as a context injector in a LangChain pipeline.

Suggested approach

```python
from langchain_openai import ChatOpenAI
from langchain_core.messages import SystemMessage, HumanMessage
import nouse

brain = nouse.attach()
llm = ChatOpenAI(model="gpt-4.1-mini")

question = "Explain the relationship between attention and memory in transformers."
context = brain.query(question).context_block()

messages = [
SystemMessage(content=context),
HumanMessage(content=question),
]

response = llm.invoke(messages)
print(response.content)
```

Notes

  • Keep it minimal — the pattern is the point, not the chain depth
  • A comment explaining where NoUse fits (context injector before the LLM call) is more valuable than boilerplate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions