answersnap 0.2.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.
- answersnap-0.2.0/.gitignore +8 -0
- answersnap-0.2.0/LICENSE +201 -0
- answersnap-0.2.0/PKG-INFO +135 -0
- answersnap-0.2.0/README.md +116 -0
- answersnap-0.2.0/pyproject.toml +39 -0
- answersnap-0.2.0/src/answersnap/__init__.py +8 -0
- answersnap-0.2.0/src/answersnap/cli.py +265 -0
- answersnap-0.2.0/src/answersnap/config.py +208 -0
- answersnap-0.2.0/src/answersnap/engines.py +213 -0
- answersnap-0.2.0/src/answersnap/examples/__init__.py +0 -0
- answersnap-0.2.0/src/answersnap/examples/example.yaml +46 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/anthropic.json +406 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/google.json +339 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/openai.json +343 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/pages/coffeeguide-freshness.html +8 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/pages/example-coffee-espresso-starter.html +9 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/pages/example-coffee-shipping.html +7 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/pages/index.json +9 -0
- answersnap-0.2.0/src/answersnap/examples/fixtures/pages/sample-roasters-subscriptions.html +7 -0
- answersnap-0.2.0/src/answersnap/faithfulness.py +279 -0
- answersnap-0.2.0/src/answersnap/fetch/__init__.py +0 -0
- answersnap-0.2.0/src/answersnap/fetch/robots.py +59 -0
- answersnap-0.2.0/src/answersnap/fetch/safe_fetch.py +199 -0
- answersnap-0.2.0/src/answersnap/metrics/__init__.py +0 -0
- answersnap-0.2.0/src/answersnap/metrics/excerpt.py +71 -0
- answersnap-0.2.0/src/answersnap/metrics/mention.py +221 -0
- answersnap-0.2.0/src/answersnap/metrics/rates.py +143 -0
- answersnap-0.2.0/src/answersnap/metrics/retrieval_gap.py +208 -0
- answersnap-0.2.0/src/answersnap/metrics/stats.py +23 -0
- answersnap-0.2.0/src/answersnap/metrics/usage.py +43 -0
- answersnap-0.2.0/src/answersnap/pricing.py +93 -0
- answersnap-0.2.0/src/answersnap/providers/__init__.py +24 -0
- answersnap-0.2.0/src/answersnap/providers/anthropic_provider.py +265 -0
- answersnap-0.2.0/src/answersnap/providers/base.py +225 -0
- answersnap-0.2.0/src/answersnap/providers/citation_host.py +59 -0
- answersnap-0.2.0/src/answersnap/providers/google_provider.py +237 -0
- answersnap-0.2.0/src/answersnap/providers/http.py +67 -0
- answersnap-0.2.0/src/answersnap/providers/openai_provider.py +214 -0
- answersnap-0.2.0/src/answersnap/providers/perplexity_provider.py +107 -0
- answersnap-0.2.0/src/answersnap/providers/recorded/anthropic.json +370 -0
- answersnap-0.2.0/src/answersnap/providers/recorded/google.json +358 -0
- answersnap-0.2.0/src/answersnap/providers/recorded/openai.json +225 -0
- answersnap-0.2.0/src/answersnap/providers/spans.py +86 -0
- answersnap-0.2.0/src/answersnap/providers/xai_provider.py +131 -0
- answersnap-0.2.0/src/answersnap/report/__init__.py +51 -0
- answersnap-0.2.0/src/answersnap/report/build.py +223 -0
- answersnap-0.2.0/src/answersnap/report/format.py +168 -0
- answersnap-0.2.0/src/answersnap/report/html.py +29 -0
- answersnap-0.2.0/src/answersnap/report/markdown.py +158 -0
- answersnap-0.2.0/src/answersnap/report/templates/report.html.j2 +171 -0
- answersnap-0.2.0/src/answersnap/run.py +292 -0
- answersnap-0.2.0/src/answersnap/store.py +267 -0
- answersnap-0.2.0/tests/builders.py +63 -0
- answersnap-0.2.0/tests/conftest.py +7 -0
- answersnap-0.2.0/tests/e2e/test_cli.py +278 -0
- answersnap-0.2.0/tests/fake_answers.py +103 -0
- answersnap-0.2.0/tests/integration/test_report_generate.py +192 -0
- answersnap-0.2.0/tests/integration/test_run_loop.py +332 -0
- answersnap-0.2.0/tests/security/test_security.py +156 -0
- answersnap-0.2.0/tests/unit/test_anthropic_provider.py +228 -0
- answersnap-0.2.0/tests/unit/test_citation_host.py +54 -0
- answersnap-0.2.0/tests/unit/test_config.py +149 -0
- answersnap-0.2.0/tests/unit/test_engines.py +132 -0
- answersnap-0.2.0/tests/unit/test_excerpt.py +66 -0
- answersnap-0.2.0/tests/unit/test_faithfulness.py +236 -0
- answersnap-0.2.0/tests/unit/test_format.py +54 -0
- answersnap-0.2.0/tests/unit/test_http_retry.py +158 -0
- answersnap-0.2.0/tests/unit/test_mention_extraction.py +146 -0
- answersnap-0.2.0/tests/unit/test_pricing.py +45 -0
- answersnap-0.2.0/tests/unit/test_provider_parsers.py +317 -0
- answersnap-0.2.0/tests/unit/test_provider_transport_errors.py +60 -0
- answersnap-0.2.0/tests/unit/test_rates.py +104 -0
- answersnap-0.2.0/tests/unit/test_record_capture.py +238 -0
- answersnap-0.2.0/tests/unit/test_retrieval_gap.py +58 -0
- answersnap-0.2.0/tests/unit/test_retrieved_set_availability.py +73 -0
- answersnap-0.2.0/tests/unit/test_robots.py +67 -0
- answersnap-0.2.0/tests/unit/test_safe_fetch.py +174 -0
- answersnap-0.2.0/tests/unit/test_spans.py +78 -0
- answersnap-0.2.0/tests/unit/test_split_guard.py +24 -0
- answersnap-0.2.0/tests/unit/test_stats.py +29 -0
- answersnap-0.2.0/tests/unit/test_store.py +160 -0
- answersnap-0.2.0/tests/unit/test_verification_gate.py +142 -0
answersnap-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: answersnap
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Auditable AI-visibility snapshots: what ChatGPT, Claude and Gemini actually said about a brand, with the evidence kept.
|
|
5
|
+
Project-URL: Homepage, https://github.com/GGaryyy/answersnap
|
|
6
|
+
Project-URL: Issues, https://github.com/GGaryyy/answersnap/issues
|
|
7
|
+
License-Expression: Apache-2.0
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: ai-visibility,audit,generative-engine-optimization,geo,llm
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Requires-Dist: anthropic>=0.40
|
|
12
|
+
Requires-Dist: jinja2>=3.1
|
|
13
|
+
Requires-Dist: openai>=1.60
|
|
14
|
+
Requires-Dist: pydantic>=2.9
|
|
15
|
+
Requires-Dist: pyyaml>=6.0
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=8.3; extra == 'dev'
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# answersnap
|
|
21
|
+
|
|
22
|
+
**Auditable AI-visibility snapshots (GEO).** Ask ChatGPT, Claude and Gemini the questions your buyers ask, keep every answer word for word, and get a report where every number links back to the answers it came from.
|
|
23
|
+
|
|
24
|
+
Most AI-visibility tools give you one score. `answersnap` gives you the evidence behind it instead:
|
|
25
|
+
|
|
26
|
+
- **Engines are never averaged.** Claude, ChatGPT and Gemini are reported side by side, each with its own rate.
|
|
27
|
+
- **Every rate has its count and a 95% interval.** For example: named in 4 of 9 answers (44%, 95% CI 19–73%). Under 10 answers, the rate is marked *low sample*.
|
|
28
|
+
- **Mention, recommendation-question answers and citation are separate columns.** They are not blended into one number.
|
|
29
|
+
- **Each answer is asked several times.** One answer is a coin flip.
|
|
30
|
+
- **The full answer text is stored as JSON**, one file per answer, along with model ids, dates and a hash of the exact questions.
|
|
31
|
+
- **Citation faithfulness.** When an engine returns the text it quoted, `answersnap` fetches the cited page and checks whether the quote is actually on it.
|
|
32
|
+
- **"Not observable" is never shown as 0.** When an engine hides its sources, the report says so instead of printing 0%.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pipx install git+https://github.com/GGaryyy/answersnap
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Python 3.11+. (Not on PyPI yet.)
|
|
41
|
+
|
|
42
|
+
## Five-minute dry run (no API keys, no cost)
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
answersnap init # writes answersnap.yaml (a fictional coffee brand)
|
|
46
|
+
answersnap run --config answersnap.yaml --dry-run
|
|
47
|
+
open output/answersnap/example-coffee-co/*/report.html
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The dry run answers from bundled fictional fixtures and makes no network calls, so you can see the full report before spending anything.
|
|
51
|
+
|
|
52
|
+
## A real run
|
|
53
|
+
|
|
54
|
+
1. Edit `answersnap.yaml`:
|
|
55
|
+
- your brand and every alias it goes by
|
|
56
|
+
- your owned domains
|
|
57
|
+
- your competitors
|
|
58
|
+
- the questions your buyers actually ask
|
|
59
|
+
2. Set an API key for each engine you want: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY` (`GOOGLE_API_KEY` also works). Engines without a key are skipped, and the report names them.
|
|
60
|
+
3. Check your setup, then run:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
answersnap doctor --config answersnap.yaml
|
|
64
|
+
answersnap run --config answersnap.yaml # prints the plan and an estimate, then asks before spending
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The estimate before a run prices one typical recorded call per engine at list price. After a run, each answer is priced from its own reported token usage at the list prices in `pricing.py`, dated in the report. It is an estimate, not a bill: discounts, free allowances and price changes are not reflected, and a model without a listed price gets no estimate.
|
|
68
|
+
|
|
69
|
+
Useful flags:
|
|
70
|
+
|
|
71
|
+
| Flag | What it does |
|
|
72
|
+
|---|---|
|
|
73
|
+
| `--max-calls N` | Caps the spend |
|
|
74
|
+
| `--engines anthropic,openai` | Runs a subset of engines |
|
|
75
|
+
| `--resume RUN_DIR` | Fills in an interrupted run |
|
|
76
|
+
| `--no-fetch` | Skips fetching cited pages |
|
|
77
|
+
| `--no-raw` | Does not keep each full API response (`q00_r0.raw.json`) |
|
|
78
|
+
| `--yes` | Skips the confirmation prompt (for scripts) |
|
|
79
|
+
|
|
80
|
+
Rebuild a report from its directory at any time:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
answersnap report output/answersnap/<brand>/<run_id>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
The report is built only from the run directory. Editing your config afterwards cannot change it.
|
|
87
|
+
|
|
88
|
+
## What a run directory contains
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
manifest.json models, dates, prompt-set version + hash, calls planned/made/failed
|
|
92
|
+
config.frozen.json the config as it was when the run started
|
|
93
|
+
answers/<engine>/q00_r0.json answer text, citations, search queries, cited spans, token usage
|
|
94
|
+
answers/<engine>/q00_r0.raw.json the full API response as the SDK returned it (skipped with --no-raw)
|
|
95
|
+
answers/<engine>/q00_r0.error.json a failed call, kept, not hidden
|
|
96
|
+
fetched/<hash>.json cited pages as fetched, for the faithfulness check
|
|
97
|
+
report.json / report.md / report.html
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The raw file is the SDK's JSON form of the response, written with sorted keys. It is not the bytes on the wire. Each answer record names its raw file with a SHA-256 digest, so you can confirm the file has not changed since the run. The parsed record is enough to rebuild the report. The raw response is what lets you re-check the parsing, or extract something new from an old run later. Raw files run to tens of KB per answer.
|
|
101
|
+
|
|
102
|
+
**Keep run directories private.** They hold full engine output and passages quoted from the pages the engines cited. Do not commit them to a public repository or publish them.
|
|
103
|
+
|
|
104
|
+
Directories from v0.1 (`answer-1` records) still report. Fields they never captured show as "not recorded", and a resumed v0.1 run lists both record schemas in the report.
|
|
105
|
+
|
|
106
|
+
## Measurement rules
|
|
107
|
+
|
|
108
|
+
- **Questions are frozen per version.** Changing any question's text or intent means bumping `prompt_set.version`. `answersnap` refuses to mix answers to different questions under one version.
|
|
109
|
+
- **Every call is a fresh conversation.** The question is sent verbatim, with no system prompt and the provider's default temperature, using the consumer-default model tier with web search on.
|
|
110
|
+
- **Mention matching is deterministic string matching** on your aliases. No language model decides whether you were mentioned.
|
|
111
|
+
- **"Named in recommendation answers" is not "recommended".** It counts answers to recommendation-intent questions that name you, so an answer that names you to warn against you still counts. Read the sentence column. Sentence-level judgment is planned.
|
|
112
|
+
- **Faithfulness has no pass/fail threshold.** A quote is either "found verbatim" on the page, or "not found verbatim" with an overlap score. Pages change, render with JavaScript and sit behind paywalls, so a low score is a lead to check, not a verdict.
|
|
113
|
+
- In v0.1 only Claude returns quoted text.
|
|
114
|
+
- ChatGPT and Gemini return links without quotes, so their faithfulness is reported as not observable.
|
|
115
|
+
- **Fetching cited pages is guarded.** Every redirect hop is re-checked against private, loopback and link-local addresses, and robots.txt is honoured.
|
|
116
|
+
|
|
117
|
+
## Engines
|
|
118
|
+
|
|
119
|
+
| Engine | Model (consumer default) | Citations | Quoted text | Search queries | Cited spans | Token usage |
|
|
120
|
+
|---|---|---|---|---|---|---|
|
|
121
|
+
| Claude (`anthropic`) | claude-sonnet-5 | yes | yes | yes, with result counts | whole cited passages | yes, plus billed search count |
|
|
122
|
+
| ChatGPT (`openai`) | gpt-5.1 | yes | no | yes | character ranges | yes, plus billed search count |
|
|
123
|
+
| Gemini (`google`) | gemini-3.7-flash | yes (resolved from redirects) | no | yes | byte ranges, converted and checked against the quoted segment | yes; no search count |
|
|
124
|
+
|
|
125
|
+
An engine is only allowed to produce data after its parser has handled a real recorded response. See `answersnap verify-providers`. Adapters for Perplexity and xAI exist but are not enabled yet, because they have not passed this check.
|
|
126
|
+
|
|
127
|
+
## Known limits
|
|
128
|
+
|
|
129
|
+
- One snapshot per run. Comparing two snapshots is planned; until then, use the intervals: a change smaller than them is not a change.
|
|
130
|
+
- The unknown-entity patterns in `metrics/mention.py` are tuned for one category and are not used by the CLI yet.
|
|
131
|
+
- Cost figures are list-price estimates, not bills. Gemini reports no search count, so its search charges are not included. A model without a listed price gets no estimate.
|
|
132
|
+
|
|
133
|
+
## License
|
|
134
|
+
|
|
135
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# answersnap
|
|
2
|
+
|
|
3
|
+
**Auditable AI-visibility snapshots (GEO).** Ask ChatGPT, Claude and Gemini the questions your buyers ask, keep every answer word for word, and get a report where every number links back to the answers it came from.
|
|
4
|
+
|
|
5
|
+
Most AI-visibility tools give you one score. `answersnap` gives you the evidence behind it instead:
|
|
6
|
+
|
|
7
|
+
- **Engines are never averaged.** Claude, ChatGPT and Gemini are reported side by side, each with its own rate.
|
|
8
|
+
- **Every rate has its count and a 95% interval.** For example: named in 4 of 9 answers (44%, 95% CI 19–73%). Under 10 answers, the rate is marked *low sample*.
|
|
9
|
+
- **Mention, recommendation-question answers and citation are separate columns.** They are not blended into one number.
|
|
10
|
+
- **Each answer is asked several times.** One answer is a coin flip.
|
|
11
|
+
- **The full answer text is stored as JSON**, one file per answer, along with model ids, dates and a hash of the exact questions.
|
|
12
|
+
- **Citation faithfulness.** When an engine returns the text it quoted, `answersnap` fetches the cited page and checks whether the quote is actually on it.
|
|
13
|
+
- **"Not observable" is never shown as 0.** When an engine hides its sources, the report says so instead of printing 0%.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pipx install git+https://github.com/GGaryyy/answersnap
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Python 3.11+. (Not on PyPI yet.)
|
|
22
|
+
|
|
23
|
+
## Five-minute dry run (no API keys, no cost)
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
answersnap init # writes answersnap.yaml (a fictional coffee brand)
|
|
27
|
+
answersnap run --config answersnap.yaml --dry-run
|
|
28
|
+
open output/answersnap/example-coffee-co/*/report.html
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The dry run answers from bundled fictional fixtures and makes no network calls, so you can see the full report before spending anything.
|
|
32
|
+
|
|
33
|
+
## A real run
|
|
34
|
+
|
|
35
|
+
1. Edit `answersnap.yaml`:
|
|
36
|
+
- your brand and every alias it goes by
|
|
37
|
+
- your owned domains
|
|
38
|
+
- your competitors
|
|
39
|
+
- the questions your buyers actually ask
|
|
40
|
+
2. Set an API key for each engine you want: `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GEMINI_API_KEY` (`GOOGLE_API_KEY` also works). Engines without a key are skipped, and the report names them.
|
|
41
|
+
3. Check your setup, then run:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
answersnap doctor --config answersnap.yaml
|
|
45
|
+
answersnap run --config answersnap.yaml # prints the plan and an estimate, then asks before spending
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The estimate before a run prices one typical recorded call per engine at list price. After a run, each answer is priced from its own reported token usage at the list prices in `pricing.py`, dated in the report. It is an estimate, not a bill: discounts, free allowances and price changes are not reflected, and a model without a listed price gets no estimate.
|
|
49
|
+
|
|
50
|
+
Useful flags:
|
|
51
|
+
|
|
52
|
+
| Flag | What it does |
|
|
53
|
+
|---|---|
|
|
54
|
+
| `--max-calls N` | Caps the spend |
|
|
55
|
+
| `--engines anthropic,openai` | Runs a subset of engines |
|
|
56
|
+
| `--resume RUN_DIR` | Fills in an interrupted run |
|
|
57
|
+
| `--no-fetch` | Skips fetching cited pages |
|
|
58
|
+
| `--no-raw` | Does not keep each full API response (`q00_r0.raw.json`) |
|
|
59
|
+
| `--yes` | Skips the confirmation prompt (for scripts) |
|
|
60
|
+
|
|
61
|
+
Rebuild a report from its directory at any time:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
answersnap report output/answersnap/<brand>/<run_id>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The report is built only from the run directory. Editing your config afterwards cannot change it.
|
|
68
|
+
|
|
69
|
+
## What a run directory contains
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
manifest.json models, dates, prompt-set version + hash, calls planned/made/failed
|
|
73
|
+
config.frozen.json the config as it was when the run started
|
|
74
|
+
answers/<engine>/q00_r0.json answer text, citations, search queries, cited spans, token usage
|
|
75
|
+
answers/<engine>/q00_r0.raw.json the full API response as the SDK returned it (skipped with --no-raw)
|
|
76
|
+
answers/<engine>/q00_r0.error.json a failed call, kept, not hidden
|
|
77
|
+
fetched/<hash>.json cited pages as fetched, for the faithfulness check
|
|
78
|
+
report.json / report.md / report.html
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
The raw file is the SDK's JSON form of the response, written with sorted keys. It is not the bytes on the wire. Each answer record names its raw file with a SHA-256 digest, so you can confirm the file has not changed since the run. The parsed record is enough to rebuild the report. The raw response is what lets you re-check the parsing, or extract something new from an old run later. Raw files run to tens of KB per answer.
|
|
82
|
+
|
|
83
|
+
**Keep run directories private.** They hold full engine output and passages quoted from the pages the engines cited. Do not commit them to a public repository or publish them.
|
|
84
|
+
|
|
85
|
+
Directories from v0.1 (`answer-1` records) still report. Fields they never captured show as "not recorded", and a resumed v0.1 run lists both record schemas in the report.
|
|
86
|
+
|
|
87
|
+
## Measurement rules
|
|
88
|
+
|
|
89
|
+
- **Questions are frozen per version.** Changing any question's text or intent means bumping `prompt_set.version`. `answersnap` refuses to mix answers to different questions under one version.
|
|
90
|
+
- **Every call is a fresh conversation.** The question is sent verbatim, with no system prompt and the provider's default temperature, using the consumer-default model tier with web search on.
|
|
91
|
+
- **Mention matching is deterministic string matching** on your aliases. No language model decides whether you were mentioned.
|
|
92
|
+
- **"Named in recommendation answers" is not "recommended".** It counts answers to recommendation-intent questions that name you, so an answer that names you to warn against you still counts. Read the sentence column. Sentence-level judgment is planned.
|
|
93
|
+
- **Faithfulness has no pass/fail threshold.** A quote is either "found verbatim" on the page, or "not found verbatim" with an overlap score. Pages change, render with JavaScript and sit behind paywalls, so a low score is a lead to check, not a verdict.
|
|
94
|
+
- In v0.1 only Claude returns quoted text.
|
|
95
|
+
- ChatGPT and Gemini return links without quotes, so their faithfulness is reported as not observable.
|
|
96
|
+
- **Fetching cited pages is guarded.** Every redirect hop is re-checked against private, loopback and link-local addresses, and robots.txt is honoured.
|
|
97
|
+
|
|
98
|
+
## Engines
|
|
99
|
+
|
|
100
|
+
| Engine | Model (consumer default) | Citations | Quoted text | Search queries | Cited spans | Token usage |
|
|
101
|
+
|---|---|---|---|---|---|---|
|
|
102
|
+
| Claude (`anthropic`) | claude-sonnet-5 | yes | yes | yes, with result counts | whole cited passages | yes, plus billed search count |
|
|
103
|
+
| ChatGPT (`openai`) | gpt-5.1 | yes | no | yes | character ranges | yes, plus billed search count |
|
|
104
|
+
| Gemini (`google`) | gemini-3.7-flash | yes (resolved from redirects) | no | yes | byte ranges, converted and checked against the quoted segment | yes; no search count |
|
|
105
|
+
|
|
106
|
+
An engine is only allowed to produce data after its parser has handled a real recorded response. See `answersnap verify-providers`. Adapters for Perplexity and xAI exist but are not enabled yet, because they have not passed this check.
|
|
107
|
+
|
|
108
|
+
## Known limits
|
|
109
|
+
|
|
110
|
+
- One snapshot per run. Comparing two snapshots is planned; until then, use the intervals: a change smaller than them is not a change.
|
|
111
|
+
- The unknown-entity patterns in `metrics/mention.py` are tuned for one category and are not used by the CLI yet.
|
|
112
|
+
- Cost figures are list-price estimates, not bills. Gemini reports no search count, so its search charges are not included. A model without a listed price gets no estimate.
|
|
113
|
+
|
|
114
|
+
## License
|
|
115
|
+
|
|
116
|
+
Apache-2.0. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.26"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "answersnap"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "Auditable AI-visibility snapshots: what ChatGPT, Claude and Gemini actually said about a brand, with the evidence kept."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
license = "Apache-2.0"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
keywords = ["geo", "generative-engine-optimization", "ai-visibility", "llm", "audit"]
|
|
14
|
+
dependencies = [
|
|
15
|
+
"anthropic>=0.40",
|
|
16
|
+
"openai>=1.60",
|
|
17
|
+
"pydantic>=2.9",
|
|
18
|
+
"pyyaml>=6.0",
|
|
19
|
+
"jinja2>=3.1",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/GGaryyy/answersnap"
|
|
24
|
+
Issues = "https://github.com/GGaryyy/answersnap/issues"
|
|
25
|
+
|
|
26
|
+
[project.optional-dependencies]
|
|
27
|
+
dev = ["pytest>=8.3"]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
answersnap = "answersnap.cli:main"
|
|
31
|
+
|
|
32
|
+
[tool.hatch.build.targets.sdist]
|
|
33
|
+
exclude = [".github", "uv.lock"]
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/answersnap"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""answersnap: auditable snapshots of what AI answer engines say about a brand."""
|
|
2
|
+
|
|
3
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
4
|
+
|
|
5
|
+
try:
|
|
6
|
+
__version__ = version("answersnap")
|
|
7
|
+
except PackageNotFoundError: # running from a source checkout that was never installed
|
|
8
|
+
__version__ = "0.0.0+unknown"
|