quark-agents 0.1.0__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.
@@ -0,0 +1,17 @@
1
+ MIT No Attribution
2
+
3
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: quark-agents
3
+ Version: 0.1.0
4
+ Summary: Minimal Python framework for composing agents, tools, and multi-agent workflows
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ License-File: LICENSE
9
+ Requires-Dist: litellm>=1.0.0
10
+ Provides-Extra: bedrock
11
+ Requires-Dist: boto3>=1.28.0; extra == "bedrock"
12
+ Provides-Extra: otel
13
+ Requires-Dist: opentelemetry-sdk>=1.20.0; extra == "otel"
14
+ Requires-Dist: opentelemetry-exporter-otlp-proto-http>=1.20.0; extra == "otel"
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest>=7.0; extra == "dev"
17
+ Requires-Dist: pytest-mock>=3.0; extra == "dev"
18
+ Requires-Dist: mkdocs>=1.5; extra == "dev"
19
+ Requires-Dist: mkdocs-material>=9.0; extra == "dev"
20
+ Dynamic: license-file
21
+
22
+ # Quark
23
+
24
+ A <300-line Python agentic framework. Define agents with a system prompt and tools, then compose them into pipelines using the `>>` operator — just like Airflow, but for LLMs. Provider-agnostic via [litellm](https://github.com/BerriAI/litellm).
25
+
26
+ ## Install
27
+
28
+ ```bash
29
+ # From PyPI (once available)
30
+ pip install quark-agents
31
+
32
+ # From source
33
+ git clone https://github.com/awslabs/quark-agents
34
+ cd quark-agents
35
+ pip install .
36
+
37
+ # With OpenTelemetry support
38
+ pip install "quark-agents[otel]"
39
+ ```
40
+
41
+ ### Install with uv
42
+
43
+ ```bash
44
+ git clone https://github.com/awslabs/quark-agents
45
+ cd quark-agents
46
+ uv venv
47
+ source .venv/bin/activate
48
+
49
+ # Core + dev dependencies (pytest, mkdocs)
50
+ uv pip install ".[dev]"
51
+
52
+ # With OpenTelemetry
53
+ uv pip install ".[dev,otel]"
54
+
55
+ # With AWS Bedrock support
56
+ uv pip install ".[dev,bedrock]"
57
+
58
+ # All extras
59
+ uv pip install ".[dev,otel,bedrock]"
60
+ ```
61
+
62
+ > **Note:** Editable installs (`-e`) require `setuptools>=75`. If you see
63
+ > `ModuleNotFoundError: No module named 'setuptools.backends'`, make sure
64
+ > `pyproject.toml` has `requires = ["setuptools>=75"]` under `[build-system]`,
65
+ > or use a non-editable install (`uv pip install ".[dev]"` without `-e`).
66
+
67
+ ## Usage
68
+
69
+ ### Single agent
70
+
71
+ ```python
72
+ from quark import Agent
73
+
74
+ agent = Agent(
75
+ system="You are a helpful assistant.",
76
+ model="gpt-5.4", # or any litellm-supported model
77
+ name="assistant",
78
+ )
79
+
80
+ print(agent.run("What is the capital of France?"))
81
+ ```
82
+
83
+ ### Agent with tools
84
+
85
+ ```python
86
+ def get_weather(city: str) -> str:
87
+ """Get the current weather for a city."""
88
+ return f"Sunny, 22°C in {city}"
89
+
90
+ agent = Agent(
91
+ system="You are a weather assistant.",
92
+ model="gpt-5.4",
93
+ tools={"get_weather": get_weather},
94
+ )
95
+
96
+ print(agent.run("What's the weather in Paris?"))
97
+ ```
98
+
99
+ ### Pipelines with `>>`
100
+
101
+ Chain agents and plain functions using `>>`. Output of each step becomes input to the next.
102
+
103
+ ```python
104
+ from quark import Agent
105
+
106
+ def fetch_article(url: str) -> str:
107
+ """Fetch article content from a URL."""
108
+ return "..." # your fetch logic
109
+
110
+ summarizer = Agent(system="Summarize the article in 3 bullet points.", name="summarizer")
111
+ critic = Agent(system="List 2 weaknesses in this summary.", name="critic")
112
+ editor = Agent(system="Write a final improved summary given the feedback.", name="editor")
113
+
114
+ pipeline = fetch_article >> summarizer >> critic >> editor
115
+ result = pipeline.run("https://example.com/article")
116
+ ```
117
+
118
+ ### Parallel fan-out with lists
119
+
120
+ Wrap steps in a list to run them in parallel. Their outputs are combined and passed to the next step.
121
+
122
+ ```python
123
+ pipeline = fetch_article >> summarizer >> [critic, fact_checker] >> editor
124
+ result = pipeline.run("https://example.com/article")
125
+ ```
126
+
127
+ ### Composing workflows
128
+
129
+ ```python
130
+ research = fetch_article >> summarizer
131
+ review = [critic, fact_checker] >> editor
132
+
133
+ pipeline = research >> review
134
+ result = pipeline.run("https://example.com/article")
135
+ ```
136
+
137
+ ### Streaming
138
+
139
+ ```python
140
+ for chunk in agent.stream("Tell me a story."):
141
+ print(chunk, end="", flush=True)
142
+ ```
143
+
144
+ ### Provider-agnostic
145
+
146
+ ```python
147
+ # OpenAI
148
+ agent = Agent(model="gpt-5.4")
149
+
150
+ # Anthropic
151
+ agent = Agent(model="claude-opus-4-6")
152
+
153
+ # AWS Bedrock
154
+ agent = Agent(model="bedrock/anthropic.claude-3-5-haiku-20241022-v1:0")
155
+
156
+ # Gemini
157
+ agent = Agent(model="gemini/gemini-2.0-flash")
158
+
159
+ # Ollama (local)
160
+ agent = Agent(model="ollama/llama3")
161
+ ```
162
+
163
+ ### Observability (OpenTelemetry)
164
+
165
+ Set environment variables — tracing is enabled automatically.
166
+
167
+ ```bash
168
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
169
+ export OTEL_SERVICE_NAME=my-app
170
+ ```
171
+
172
+ Every `Agent.run()`, `Workflow.run()`, and tool call emits OTel spans. Compatible with Jaeger, Honeycomb, Grafana Tempo, Datadog, and any OTLP-compatible backend.
173
+
174
+ ## API
175
+
176
+ ### `Agent(*, system, tools, model, max_turns, name)`
177
+
178
+ | Parameter | Default | Description |
179
+ |-----------|---------|-------------|
180
+ | `system` | `"You are a helpful assistant."` | System prompt |
181
+ | `tools` | `{}` | Dict of `{name: callable}` |
182
+ | `model` | `"gpt-5.4"` | Any litellm model string |
183
+ | `max_turns` | `10` | Max LLM iterations per `run()` call |
184
+ | `name` | `"agent"` | Name used in traces and pipeline display |
185
+
186
+ **Methods:**
187
+ - `agent.run(user: str) -> str` — blocking, returns final answer
188
+ - `agent.stream(user: str) -> Generator` — yields tokens as they arrive
189
+ - `agent.reset()` — clears conversation history, keeps system prompt
190
+
191
+ ### `Workflow`
192
+
193
+ Created automatically by `>>`. Call `.run(input: str) -> str` to execute.
194
+
195
+ ```python
196
+ workflow = agent_a >> agent_b >> agent_c
197
+ result = workflow.run("input")
198
+ ```
199
+
200
+ ## Tests
201
+
202
+ ```bash
203
+ # Unit tests (no API calls)
204
+ pytest tests/
205
+
206
+ # Integration tests (requires API credentials)
207
+ pytest tests/ -m integration
208
+ ```
209
+
210
+ If using uv, prefix with `uv run` to ensure the venv's Python is used (avoids conflicts with conda or system Python):
211
+
212
+ ```bash
213
+ uv run pytest tests/
214
+ uv run pytest tests/ -m "not integration"
215
+ uv run pytest tests/ -m integration
216
+ ```
217
+
218
+ ## Why Quark?
219
+
220
+ Named after the smallest known fundamental particles — quarks need gluons to bind them together. Quark is the minimal binding layer for AI agents.
@@ -0,0 +1,199 @@
1
+ # Quark
2
+
3
+ A <300-line Python agentic framework. Define agents with a system prompt and tools, then compose them into pipelines using the `>>` operator — just like Airflow, but for LLMs. Provider-agnostic via [litellm](https://github.com/BerriAI/litellm).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ # From PyPI (once available)
9
+ pip install quark-agents
10
+
11
+ # From source
12
+ git clone https://github.com/awslabs/quark-agents
13
+ cd quark-agents
14
+ pip install .
15
+
16
+ # With OpenTelemetry support
17
+ pip install "quark-agents[otel]"
18
+ ```
19
+
20
+ ### Install with uv
21
+
22
+ ```bash
23
+ git clone https://github.com/awslabs/quark-agents
24
+ cd quark-agents
25
+ uv venv
26
+ source .venv/bin/activate
27
+
28
+ # Core + dev dependencies (pytest, mkdocs)
29
+ uv pip install ".[dev]"
30
+
31
+ # With OpenTelemetry
32
+ uv pip install ".[dev,otel]"
33
+
34
+ # With AWS Bedrock support
35
+ uv pip install ".[dev,bedrock]"
36
+
37
+ # All extras
38
+ uv pip install ".[dev,otel,bedrock]"
39
+ ```
40
+
41
+ > **Note:** Editable installs (`-e`) require `setuptools>=75`. If you see
42
+ > `ModuleNotFoundError: No module named 'setuptools.backends'`, make sure
43
+ > `pyproject.toml` has `requires = ["setuptools>=75"]` under `[build-system]`,
44
+ > or use a non-editable install (`uv pip install ".[dev]"` without `-e`).
45
+
46
+ ## Usage
47
+
48
+ ### Single agent
49
+
50
+ ```python
51
+ from quark import Agent
52
+
53
+ agent = Agent(
54
+ system="You are a helpful assistant.",
55
+ model="gpt-5.4", # or any litellm-supported model
56
+ name="assistant",
57
+ )
58
+
59
+ print(agent.run("What is the capital of France?"))
60
+ ```
61
+
62
+ ### Agent with tools
63
+
64
+ ```python
65
+ def get_weather(city: str) -> str:
66
+ """Get the current weather for a city."""
67
+ return f"Sunny, 22°C in {city}"
68
+
69
+ agent = Agent(
70
+ system="You are a weather assistant.",
71
+ model="gpt-5.4",
72
+ tools={"get_weather": get_weather},
73
+ )
74
+
75
+ print(agent.run("What's the weather in Paris?"))
76
+ ```
77
+
78
+ ### Pipelines with `>>`
79
+
80
+ Chain agents and plain functions using `>>`. Output of each step becomes input to the next.
81
+
82
+ ```python
83
+ from quark import Agent
84
+
85
+ def fetch_article(url: str) -> str:
86
+ """Fetch article content from a URL."""
87
+ return "..." # your fetch logic
88
+
89
+ summarizer = Agent(system="Summarize the article in 3 bullet points.", name="summarizer")
90
+ critic = Agent(system="List 2 weaknesses in this summary.", name="critic")
91
+ editor = Agent(system="Write a final improved summary given the feedback.", name="editor")
92
+
93
+ pipeline = fetch_article >> summarizer >> critic >> editor
94
+ result = pipeline.run("https://example.com/article")
95
+ ```
96
+
97
+ ### Parallel fan-out with lists
98
+
99
+ Wrap steps in a list to run them in parallel. Their outputs are combined and passed to the next step.
100
+
101
+ ```python
102
+ pipeline = fetch_article >> summarizer >> [critic, fact_checker] >> editor
103
+ result = pipeline.run("https://example.com/article")
104
+ ```
105
+
106
+ ### Composing workflows
107
+
108
+ ```python
109
+ research = fetch_article >> summarizer
110
+ review = [critic, fact_checker] >> editor
111
+
112
+ pipeline = research >> review
113
+ result = pipeline.run("https://example.com/article")
114
+ ```
115
+
116
+ ### Streaming
117
+
118
+ ```python
119
+ for chunk in agent.stream("Tell me a story."):
120
+ print(chunk, end="", flush=True)
121
+ ```
122
+
123
+ ### Provider-agnostic
124
+
125
+ ```python
126
+ # OpenAI
127
+ agent = Agent(model="gpt-5.4")
128
+
129
+ # Anthropic
130
+ agent = Agent(model="claude-opus-4-6")
131
+
132
+ # AWS Bedrock
133
+ agent = Agent(model="bedrock/anthropic.claude-3-5-haiku-20241022-v1:0")
134
+
135
+ # Gemini
136
+ agent = Agent(model="gemini/gemini-2.0-flash")
137
+
138
+ # Ollama (local)
139
+ agent = Agent(model="ollama/llama3")
140
+ ```
141
+
142
+ ### Observability (OpenTelemetry)
143
+
144
+ Set environment variables — tracing is enabled automatically.
145
+
146
+ ```bash
147
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
148
+ export OTEL_SERVICE_NAME=my-app
149
+ ```
150
+
151
+ Every `Agent.run()`, `Workflow.run()`, and tool call emits OTel spans. Compatible with Jaeger, Honeycomb, Grafana Tempo, Datadog, and any OTLP-compatible backend.
152
+
153
+ ## API
154
+
155
+ ### `Agent(*, system, tools, model, max_turns, name)`
156
+
157
+ | Parameter | Default | Description |
158
+ |-----------|---------|-------------|
159
+ | `system` | `"You are a helpful assistant."` | System prompt |
160
+ | `tools` | `{}` | Dict of `{name: callable}` |
161
+ | `model` | `"gpt-5.4"` | Any litellm model string |
162
+ | `max_turns` | `10` | Max LLM iterations per `run()` call |
163
+ | `name` | `"agent"` | Name used in traces and pipeline display |
164
+
165
+ **Methods:**
166
+ - `agent.run(user: str) -> str` — blocking, returns final answer
167
+ - `agent.stream(user: str) -> Generator` — yields tokens as they arrive
168
+ - `agent.reset()` — clears conversation history, keeps system prompt
169
+
170
+ ### `Workflow`
171
+
172
+ Created automatically by `>>`. Call `.run(input: str) -> str` to execute.
173
+
174
+ ```python
175
+ workflow = agent_a >> agent_b >> agent_c
176
+ result = workflow.run("input")
177
+ ```
178
+
179
+ ## Tests
180
+
181
+ ```bash
182
+ # Unit tests (no API calls)
183
+ pytest tests/
184
+
185
+ # Integration tests (requires API credentials)
186
+ pytest tests/ -m integration
187
+ ```
188
+
189
+ If using uv, prefix with `uv run` to ensure the venv's Python is used (avoids conflicts with conda or system Python):
190
+
191
+ ```bash
192
+ uv run pytest tests/
193
+ uv run pytest tests/ -m "not integration"
194
+ uv run pytest tests/ -m integration
195
+ ```
196
+
197
+ ## Why Quark?
198
+
199
+ Named after the smallest known fundamental particles — quarks need gluons to bind them together. Quark is the minimal binding layer for AI agents.
@@ -0,0 +1,32 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "quark-agents"
7
+ version = "0.1.0"
8
+ description = "Minimal Python framework for composing agents, tools, and multi-agent workflows"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = { text = "MIT" }
12
+ dependencies = [
13
+ "litellm>=1.0.0",
14
+ ]
15
+
16
+ [project.optional-dependencies]
17
+ bedrock = [
18
+ "boto3>=1.28.0",
19
+ ]
20
+ otel = [
21
+ "opentelemetry-sdk>=1.20.0",
22
+ "opentelemetry-exporter-otlp-proto-http>=1.20.0",
23
+ ]
24
+ dev = [
25
+ "pytest>=7.0",
26
+ "pytest-mock>=3.0",
27
+ "mkdocs>=1.5",
28
+ "mkdocs-material>=9.0",
29
+ ]
30
+
31
+ [tool.setuptools]
32
+ py-modules = ["quark"]