chatterer 0.1.2__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- chatterer-0.1.3/PKG-INFO +150 -0
- chatterer-0.1.3/README.md +136 -0
- chatterer-0.1.3/chatterer/__init__.py +22 -0
- chatterer-0.1.3/chatterer/language_model.py +590 -0
- chatterer-0.1.3/chatterer/strategies/__init__.py +19 -0
- chatterer-0.1.3/chatterer/strategies/atom_of_thoughts.py +594 -0
- chatterer-0.1.3/chatterer/strategies/base.py +14 -0
- chatterer-0.1.3/chatterer.egg-info/PKG-INFO +150 -0
- {chatterer-0.1.2 → chatterer-0.1.3}/chatterer.egg-info/SOURCES.txt +4 -5
- chatterer-0.1.3/chatterer.egg-info/requires.txt +8 -0
- chatterer-0.1.3/pyproject.toml +15 -0
- chatterer-0.1.2/PKG-INFO +0 -213
- chatterer-0.1.2/README.md +0 -198
- chatterer-0.1.2/chatterer/__init__.py +0 -24
- chatterer-0.1.2/chatterer/llms/__init__.py +0 -20
- chatterer-0.1.2/chatterer/llms/base.py +0 -42
- chatterer-0.1.2/chatterer/llms/instructor.py +0 -127
- chatterer-0.1.2/chatterer/llms/langchain.py +0 -49
- chatterer-0.1.2/chatterer/llms/ollama.py +0 -69
- chatterer-0.1.2/chatterer.egg-info/PKG-INFO +0 -213
- chatterer-0.1.2/chatterer.egg-info/requires.txt +0 -9
- chatterer-0.1.2/pyproject.toml +0 -17
- {chatterer-0.1.2 → chatterer-0.1.3}/chatterer.egg-info/dependency_links.txt +0 -0
- {chatterer-0.1.2 → chatterer-0.1.3}/chatterer.egg-info/top_level.txt +0 -0
- {chatterer-0.1.2 → chatterer-0.1.3}/setup.cfg +0 -0
chatterer-0.1.3/PKG-INFO
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: chatterer
|
3
|
+
Version: 0.1.3
|
4
|
+
Summary: The highest-level interface for various LLM APIs.
|
5
|
+
Requires-Python: >=3.12
|
6
|
+
Description-Content-Type: text/markdown
|
7
|
+
Requires-Dist: instructor>=1.7.2
|
8
|
+
Requires-Dist: langchain>=0.3.19
|
9
|
+
Provides-Extra: all
|
10
|
+
Requires-Dist: langchain-openai>=0.3.7; extra == "all"
|
11
|
+
Requires-Dist: langchain-anthropic>=0.3.8; extra == "all"
|
12
|
+
Requires-Dist: langchain-google-genai>=2.0.10; extra == "all"
|
13
|
+
Requires-Dist: langchain-ollama>=0.2.3; extra == "all"
|
14
|
+
|
15
|
+
# Chatterer
|
16
|
+
|
17
|
+
**Simplified, Structured AI Assistant Framework**
|
18
|
+
|
19
|
+
`chatterer` is a Python library designed as a type-safe LangChain wrapper for interacting with various language models (OpenAI, Anthropic, Gemini, Ollama, etc.). It supports structured outputs via Pydantic models, plain text responses, and asynchronous calls.
|
20
|
+
|
21
|
+
The structured reasoning in `chatterer` is inspired by the [Atom-of-Thought](https://github.com/qixucen/atom) pipeline.
|
22
|
+
|
23
|
+
---
|
24
|
+
|
25
|
+
## Quick Install
|
26
|
+
|
27
|
+
```bash
|
28
|
+
pip install chatterer
|
29
|
+
```
|
30
|
+
|
31
|
+
---
|
32
|
+
|
33
|
+
## Quickstart Example
|
34
|
+
|
35
|
+
Generate text quickly using OpenAI:
|
36
|
+
|
37
|
+
```python
|
38
|
+
from chatterer import Chatterer
|
39
|
+
|
40
|
+
chat = Chatterer.openai("gpt-4o-mini")
|
41
|
+
response = chat.generate("What is the meaning of life?")
|
42
|
+
print(response)
|
43
|
+
```
|
44
|
+
|
45
|
+
Messages can be input as plain strings or structured lists:
|
46
|
+
|
47
|
+
```python
|
48
|
+
response = chat.generate([{ "role": "user", "content": "What's 2+2?" }])
|
49
|
+
print(response)
|
50
|
+
```
|
51
|
+
|
52
|
+
### Structured Output with Pydantic
|
53
|
+
|
54
|
+
```python
|
55
|
+
from pydantic import BaseModel
|
56
|
+
|
57
|
+
class AnswerModel(BaseModel):
|
58
|
+
question: str
|
59
|
+
answer: str
|
60
|
+
|
61
|
+
response = chat.generate_pydantic(AnswerModel, "What's the capital of France?")
|
62
|
+
print(response.question, response.answer)
|
63
|
+
```
|
64
|
+
|
65
|
+
### Async Example
|
66
|
+
|
67
|
+
```python
|
68
|
+
import asyncio
|
69
|
+
|
70
|
+
async def main():
|
71
|
+
response = await chat.agenerate("Explain async in Python briefly.")
|
72
|
+
print(response)
|
73
|
+
|
74
|
+
asyncio.run(main())
|
75
|
+
```
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
## Atom-of-Thought Pipeline (AoT)
|
80
|
+
|
81
|
+
`AoTPipeline` provides structured reasoning by:
|
82
|
+
|
83
|
+
- Detecting question domains (general, math, coding, philosophy, multihop).
|
84
|
+
- Decomposing questions recursively.
|
85
|
+
- Generating direct, decomposition-based, and simplified answers.
|
86
|
+
- Combining answers via ensemble.
|
87
|
+
|
88
|
+
### AoT Usage Example
|
89
|
+
|
90
|
+
```python
|
91
|
+
from chatterer import Chatterer
|
92
|
+
from chatterer.strategies import AoTStrategy, AoTPipeline
|
93
|
+
|
94
|
+
pipeline = AoTPipeline(chatterer=Chatterer.openai(), max_depth=2)
|
95
|
+
strategy = AoTStrategy(pipeline=pipeline)
|
96
|
+
|
97
|
+
question = "What would Newton discover if hit by an apple falling from 100 meters?"
|
98
|
+
answer = strategy.invoke(question)
|
99
|
+
print(answer)
|
100
|
+
```
|
101
|
+
|
102
|
+
---
|
103
|
+
|
104
|
+
## Supported Models
|
105
|
+
|
106
|
+
- **OpenAI**
|
107
|
+
- **Anthropic**
|
108
|
+
- **Google Gemini**
|
109
|
+
- **Ollama** (local models)
|
110
|
+
|
111
|
+
Initialize models easily:
|
112
|
+
|
113
|
+
```python
|
114
|
+
openai_chat = Chatterer.openai("gpt-4o-mini")
|
115
|
+
anthropic_chat = Chatterer.anthropic("claude-3-7-sonnet-20250219")
|
116
|
+
gemini_chat = Chatterer.google("gemini-2.0-flash")
|
117
|
+
ollama_chat = Chatterer.ollama("deepseek-r1:1.5b")
|
118
|
+
```
|
119
|
+
|
120
|
+
---
|
121
|
+
|
122
|
+
## Advanced Features
|
123
|
+
|
124
|
+
- **Streaming responses**
|
125
|
+
- **Async/Await support**
|
126
|
+
- **Structured outputs with Pydantic models**
|
127
|
+
|
128
|
+
---
|
129
|
+
|
130
|
+
## Logging
|
131
|
+
|
132
|
+
Built-in logging for easy debugging:
|
133
|
+
|
134
|
+
```python
|
135
|
+
import logging
|
136
|
+
logging.basicConfig(level=logging.DEBUG)
|
137
|
+
```
|
138
|
+
|
139
|
+
---
|
140
|
+
|
141
|
+
## Contributing
|
142
|
+
|
143
|
+
Feel free to open an issue or pull request.
|
144
|
+
|
145
|
+
---
|
146
|
+
|
147
|
+
## License
|
148
|
+
|
149
|
+
MIT License
|
150
|
+
|
@@ -0,0 +1,136 @@
|
|
1
|
+
# Chatterer
|
2
|
+
|
3
|
+
**Simplified, Structured AI Assistant Framework**
|
4
|
+
|
5
|
+
`chatterer` is a Python library designed as a type-safe LangChain wrapper for interacting with various language models (OpenAI, Anthropic, Gemini, Ollama, etc.). It supports structured outputs via Pydantic models, plain text responses, and asynchronous calls.
|
6
|
+
|
7
|
+
The structured reasoning in `chatterer` is inspired by the [Atom-of-Thought](https://github.com/qixucen/atom) pipeline.
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
## Quick Install
|
12
|
+
|
13
|
+
```bash
|
14
|
+
pip install chatterer
|
15
|
+
```
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
## Quickstart Example
|
20
|
+
|
21
|
+
Generate text quickly using OpenAI:
|
22
|
+
|
23
|
+
```python
|
24
|
+
from chatterer import Chatterer
|
25
|
+
|
26
|
+
chat = Chatterer.openai("gpt-4o-mini")
|
27
|
+
response = chat.generate("What is the meaning of life?")
|
28
|
+
print(response)
|
29
|
+
```
|
30
|
+
|
31
|
+
Messages can be input as plain strings or structured lists:
|
32
|
+
|
33
|
+
```python
|
34
|
+
response = chat.generate([{ "role": "user", "content": "What's 2+2?" }])
|
35
|
+
print(response)
|
36
|
+
```
|
37
|
+
|
38
|
+
### Structured Output with Pydantic
|
39
|
+
|
40
|
+
```python
|
41
|
+
from pydantic import BaseModel
|
42
|
+
|
43
|
+
class AnswerModel(BaseModel):
|
44
|
+
question: str
|
45
|
+
answer: str
|
46
|
+
|
47
|
+
response = chat.generate_pydantic(AnswerModel, "What's the capital of France?")
|
48
|
+
print(response.question, response.answer)
|
49
|
+
```
|
50
|
+
|
51
|
+
### Async Example
|
52
|
+
|
53
|
+
```python
|
54
|
+
import asyncio
|
55
|
+
|
56
|
+
async def main():
|
57
|
+
response = await chat.agenerate("Explain async in Python briefly.")
|
58
|
+
print(response)
|
59
|
+
|
60
|
+
asyncio.run(main())
|
61
|
+
```
|
62
|
+
|
63
|
+
---
|
64
|
+
|
65
|
+
## Atom-of-Thought Pipeline (AoT)
|
66
|
+
|
67
|
+
`AoTPipeline` provides structured reasoning by:
|
68
|
+
|
69
|
+
- Detecting question domains (general, math, coding, philosophy, multihop).
|
70
|
+
- Decomposing questions recursively.
|
71
|
+
- Generating direct, decomposition-based, and simplified answers.
|
72
|
+
- Combining answers via ensemble.
|
73
|
+
|
74
|
+
### AoT Usage Example
|
75
|
+
|
76
|
+
```python
|
77
|
+
from chatterer import Chatterer
|
78
|
+
from chatterer.strategies import AoTStrategy, AoTPipeline
|
79
|
+
|
80
|
+
pipeline = AoTPipeline(chatterer=Chatterer.openai(), max_depth=2)
|
81
|
+
strategy = AoTStrategy(pipeline=pipeline)
|
82
|
+
|
83
|
+
question = "What would Newton discover if hit by an apple falling from 100 meters?"
|
84
|
+
answer = strategy.invoke(question)
|
85
|
+
print(answer)
|
86
|
+
```
|
87
|
+
|
88
|
+
---
|
89
|
+
|
90
|
+
## Supported Models
|
91
|
+
|
92
|
+
- **OpenAI**
|
93
|
+
- **Anthropic**
|
94
|
+
- **Google Gemini**
|
95
|
+
- **Ollama** (local models)
|
96
|
+
|
97
|
+
Initialize models easily:
|
98
|
+
|
99
|
+
```python
|
100
|
+
openai_chat = Chatterer.openai("gpt-4o-mini")
|
101
|
+
anthropic_chat = Chatterer.anthropic("claude-3-7-sonnet-20250219")
|
102
|
+
gemini_chat = Chatterer.google("gemini-2.0-flash")
|
103
|
+
ollama_chat = Chatterer.ollama("deepseek-r1:1.5b")
|
104
|
+
```
|
105
|
+
|
106
|
+
---
|
107
|
+
|
108
|
+
## Advanced Features
|
109
|
+
|
110
|
+
- **Streaming responses**
|
111
|
+
- **Async/Await support**
|
112
|
+
- **Structured outputs with Pydantic models**
|
113
|
+
|
114
|
+
---
|
115
|
+
|
116
|
+
## Logging
|
117
|
+
|
118
|
+
Built-in logging for easy debugging:
|
119
|
+
|
120
|
+
```python
|
121
|
+
import logging
|
122
|
+
logging.basicConfig(level=logging.DEBUG)
|
123
|
+
```
|
124
|
+
|
125
|
+
---
|
126
|
+
|
127
|
+
## Contributing
|
128
|
+
|
129
|
+
Feel free to open an issue or pull request.
|
130
|
+
|
131
|
+
---
|
132
|
+
|
133
|
+
## License
|
134
|
+
|
135
|
+
MIT License
|
136
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from .language_model import Chatterer, InvokeKwargs
|
2
|
+
from .strategies import (
|
3
|
+
AoTPipeline,
|
4
|
+
AoTStrategy,
|
5
|
+
BaseAoTPrompter,
|
6
|
+
BaseStrategy,
|
7
|
+
CodingAoTPrompter,
|
8
|
+
GeneralAoTPrompter,
|
9
|
+
PhilosophyAoTPrompter,
|
10
|
+
)
|
11
|
+
|
12
|
+
__all__ = [
|
13
|
+
"BaseStrategy",
|
14
|
+
"Chatterer",
|
15
|
+
"InvokeKwargs",
|
16
|
+
"AoTStrategy",
|
17
|
+
"AoTPipeline",
|
18
|
+
"BaseAoTPrompter",
|
19
|
+
"GeneralAoTPrompter",
|
20
|
+
"CodingAoTPrompter",
|
21
|
+
"PhilosophyAoTPrompter",
|
22
|
+
]
|