├── .github
├── dependabot.yml
└── workflows
│ ├── dotnet.yml
│ └── pull-request.yml
├── .gitignore
├── LICENSE
├── Poe.sln
├── README.md
├── assets
└── nuget_icon.png
└── src
├── Directory.Build.props
├── key.snk
├── libs
├── Directory.Build.props
└── Poe
│ ├── Models
│ ├── Payload.cs
│ └── PayloadItem.cs
│ ├── PayloadGenerator.cs
│ ├── Poe.csproj
│ ├── PoeApi.Authorization.cs
│ ├── PoeApi.Constructors.cs
│ ├── PoeApi.cs
│ └── Resources
│ └── queries.json
└── tests
└── Poe.IntegrationTests
├── Poe.IntegrationTests.csproj
└── Tests.cs
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | # To get started with Dependabot version updates, you'll need to specify which
2 | # package ecosystems to update and where the package manifests are located.
3 | # Please see the documentation for all configuration options:
4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5 |
6 | version: 2
7 | updates:
8 | - package-ecosystem: "nuget" # See documentation for possible values
9 | directory: "/" # Location of package manifests
10 | schedule:
11 | interval: "weekly"
12 | groups:
13 | all:
14 | patterns:
15 | - "*"
16 |
--------------------------------------------------------------------------------
/.github/workflows/dotnet.yml:
--------------------------------------------------------------------------------
1 | name: Build, test and publish
2 | on:
3 | push:
4 | branches:
5 | - main
6 |
7 | jobs:
8 | build-test-publish:
9 | name: Build, test and publish
10 | uses: HavenDV/workflows/.github/workflows/dotnet_build-test-publish.yml@main
11 | with:
12 | generate-build-number: false
13 | conventional-commits-publish-conditions: false
14 | additional-test-arguments: '--logger GitHubActions'
15 | secrets:
16 | nuget-key: ${{ secrets.NUGET_KEY }}
--------------------------------------------------------------------------------
/.github/workflows/pull-request.yml:
--------------------------------------------------------------------------------
1 | name: Build and test
2 | on:
3 | pull_request:
4 | branches:
5 | - main
6 |
7 | jobs:
8 | build-test:
9 | name: Build abd test
10 | uses: HavenDV/workflows/.github/workflows/dotnet_build-test-publish.yml@main
11 | with:
12 | generate-build-number: false
13 | conventional-commits-publish-conditions: false
14 | enable-caching: false
15 | additional-test-arguments: '--logger GitHubActions'
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio 6 auto-generated project file (contains which files were open etc.)
298 | *.vbp
299 |
300 | # Visual Studio 6 workspace and project file (working project files containing files to include in project)
301 | *.dsw
302 | *.dsp
303 |
304 | # Visual Studio 6 technical files
305 | *.ncb
306 | *.aps
307 |
308 | # Visual Studio LightSwitch build output
309 | **/*.HTMLClient/GeneratedArtifacts
310 | **/*.DesktopClient/GeneratedArtifacts
311 | **/*.DesktopClient/ModelManifest.xml
312 | **/*.Server/GeneratedArtifacts
313 | **/*.Server/ModelManifest.xml
314 | _Pvt_Extensions
315 |
316 | # Paket dependency manager
317 | .paket/paket.exe
318 | paket-files/
319 |
320 | # FAKE - F# Make
321 | .fake/
322 |
323 | # CodeRush personal settings
324 | .cr/personal
325 |
326 | # Python Tools for Visual Studio (PTVS)
327 | __pycache__/
328 | *.pyc
329 |
330 | # Cake - Uncomment if you are using it
331 | # tools/**
332 | # !tools/packages.config
333 |
334 | # Tabs Studio
335 | *.tss
336 |
337 | # Telerik's JustMock configuration file
338 | *.jmconfig
339 |
340 | # BizTalk build output
341 | *.btp.cs
342 | *.btm.cs
343 | *.odx.cs
344 | *.xsd.cs
345 |
346 | # OpenCover UI analysis results
347 | OpenCover/
348 |
349 | # Azure Stream Analytics local run output
350 | ASALocalRun/
351 |
352 | # MSBuild Binary and Structured Log
353 | *.binlog
354 |
355 | # NVidia Nsight GPU debugger configuration file
356 | *.nvuser
357 |
358 | # MFractors (Xamarin productivity tool) working folder
359 | .mfractor/
360 |
361 | # Local History for Visual Studio
362 | .localhistory/
363 |
364 | # Visual Studio History (VSHistory) files
365 | .vshistory/
366 |
367 | # BeatPulse healthcheck temp database
368 | healthchecksdb
369 |
370 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
371 | MigrationBackup/
372 |
373 | # Ionide (cross platform F# VS Code tools) working folder
374 | .ionide/
375 |
376 | # Fody - auto-generated XML schema
377 | FodyWeavers.xsd
378 |
379 | # VS Code files for those working on multiple tools
380 | .vscode/*
381 | !.vscode/settings.json
382 | !.vscode/tasks.json
383 | !.vscode/launch.json
384 | !.vscode/extensions.json
385 | *.code-workspace
386 |
387 | # Local History for Visual Studio Code
388 | .history/
389 |
390 | # Windows Installer files from build outputs
391 | *.cab
392 | *.msi
393 | *.msix
394 | *.msm
395 | *.msp
396 |
397 | # JetBrains Rider
398 | *.sln.iml
399 | /.idea/
400 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 tryAGI
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/Poe.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30204.135
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E793AF18-4371-4EBD-96FC-195EB1798855}"
7 | ProjectSection(SolutionItems) = preProject
8 | .gitignore = .gitignore
9 | src\Directory.Build.props = src\Directory.Build.props
10 | .github\workflows\dotnet.yml = .github\workflows\dotnet.yml
11 | LICENSE = LICENSE
12 | README.md = README.md
13 | .github\workflows\pull-request.yml = .github\workflows\pull-request.yml
14 | EndProjectSection
15 | EndProject
16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "libs", "libs", "{61E7E11E-4558-434C-ACE8-06316A3097B3}"
17 | ProjectSection(SolutionItems) = preProject
18 | src\libs\Directory.Build.props = src\libs\Directory.Build.props
19 | EndProjectSection
20 | EndProject
21 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{AAA11B78-2764-4520-A97E-46AA7089A588}"
22 | EndProject
23 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Poe", "src\libs\Poe\Poe.csproj", "{B83B3177-EA27-4470-B859-B45507FC9F01}"
24 | EndProject
25 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Poe.IntegrationTests", "src\tests\Poe.IntegrationTests\Poe.IntegrationTests.csproj", "{0BBF80F4-1ED3-4082-BCDA-15FA073111D8}"
26 | EndProject
27 | Global
28 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
29 | Debug|Any CPU = Debug|Any CPU
30 | Release|Any CPU = Release|Any CPU
31 | EndGlobalSection
32 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
33 | {B83B3177-EA27-4470-B859-B45507FC9F01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {B83B3177-EA27-4470-B859-B45507FC9F01}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {B83B3177-EA27-4470-B859-B45507FC9F01}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {B83B3177-EA27-4470-B859-B45507FC9F01}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {0BBF80F4-1ED3-4082-BCDA-15FA073111D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {0BBF80F4-1ED3-4082-BCDA-15FA073111D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {0BBF80F4-1ED3-4082-BCDA-15FA073111D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {0BBF80F4-1ED3-4082-BCDA-15FA073111D8}.Release|Any CPU.Build.0 = Release|Any CPU
41 | EndGlobalSection
42 | GlobalSection(SolutionProperties) = preSolution
43 | HideSolutionNode = FALSE
44 | EndGlobalSection
45 | GlobalSection(NestedProjects) = preSolution
46 | {B83B3177-EA27-4470-B859-B45507FC9F01} = {61E7E11E-4558-434C-ACE8-06316A3097B3}
47 | {0BBF80F4-1ED3-4082-BCDA-15FA073111D8} = {AAA11B78-2764-4520-A97E-46AA7089A588}
48 | EndGlobalSection
49 | GlobalSection(ExtensibilityGlobals) = postSolution
50 | SolutionGuid = {CED9A020-DBA5-4BE6-8096-75E528648EC1}
51 | EndGlobalSection
52 | EndGlobal
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Poe
2 |
3 | [](https://www.nuget.org/packages/Poe/)
4 | [](https://github.com/tryAGI/Poe/actions/workflows/dotnet.yml)
5 | [](https://github.com/tryAGI/Poe/blob/main/LICENSE.txt)
6 | [](https://discord.gg/Ca2xhfBf3v)
7 |
8 | A reverse engineered C# API wrapper for Quora's Poe, which provides access to ChatGPT, GPT-4, and Claude.
9 |
10 | ### Usage
11 | ```csharp
12 | using Poe;
13 |
14 | using var httpClient = new HttpClient();
15 | var api = new PoeApi(apiKey, httpClient);
16 | ```
17 |
18 | ## Support
19 |
20 | Priority place for bugs: https://github.com/tryAGI/Poe/issues
21 | Priority place for ideas and general questions: https://github.com/tryAGI/Poe/discussions
22 | Discord: https://discord.gg/Ca2xhfBf3v
--------------------------------------------------------------------------------
/assets/nuget_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tryAGI/Poe/06588ae5f89deee387cd931634122692b005fcea/assets/nuget_icon.png
--------------------------------------------------------------------------------
/src/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | preview
5 | enable
6 | enable
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/key.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/tryAGI/Poe/06588ae5f89deee387cd931634122692b005fcea/src/key.snk
--------------------------------------------------------------------------------
/src/libs/Directory.Build.props:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | true
7 | $(MSBuildThisFileDirectory)../key.snk
8 |
9 |
10 |
11 |
12 | <_Parameter1>false
13 |
14 |
15 |
16 |
17 | 0.1.0
18 | true
19 | true
20 | tryAGI and contributors
21 | MIT
22 | nuget_icon.png
23 | README.md
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | true
33 | $(MSBuildThisFileDirectory)../../../LocalPackages
34 |
35 |
36 |
37 |
38 | all
39 | runtime; build; native; contentfiles; analyzers; buildtransitive
40 |
41 |
42 |
43 |
44 | true
45 | latest
46 | All
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/libs/Poe/Models/Payload.cs:
--------------------------------------------------------------------------------
1 | namespace Poe.Models;
2 |
3 | ///
4 | ///
5 | ///
6 | public class Payload
7 | {
8 | ///
9 | ///
10 | ///
11 | public IReadOnlyDictionary Extensions { get; set; } = new Dictionary();
12 |
13 | ///
14 | ///
15 | ///
16 | public string QueryName { get; set; } = string.Empty;
17 |
18 | ///
19 | ///
20 | ///
21 | public IReadOnlyDictionary Variables { get; set; } = new Dictionary();
22 | }
--------------------------------------------------------------------------------
/src/libs/Poe/Models/PayloadItem.cs:
--------------------------------------------------------------------------------
1 | namespace Poe.Models;
2 |
3 | ///
4 | ///
5 | ///
6 | public class PayloadItem
7 | {
8 | ///
9 | ///
10 | ///
11 | public string Category { get; set; } = String.Empty;
12 |
13 | ///
14 | ///
15 | ///
16 | public IReadOnlyDictionary Data { get; set; } = new Dictionary();
17 | }
--------------------------------------------------------------------------------
/src/libs/Poe/PayloadGenerator.cs:
--------------------------------------------------------------------------------
1 | using Poe.Models;
2 |
3 | namespace Poe;
4 |
5 | ///
6 | ///
7 | ///
8 | public class PayloadGenerator
9 | {
10 | private readonly Dictionary _queries =
11 | JsonSerializer.Deserialize>(H.Resources.queries_json.AsString()) ??
12 | throw new InvalidOperationException("Failed to deserialize queries.json");
13 |
14 | private readonly Random _random = new();
15 |
16 | ///
17 | ///
18 | ///
19 | ///
20 | ///
21 | ///
22 | public object GeneratePayload(string queryName, Dictionary variables)
23 | {
24 | if (queryName == "recv")
25 | {
26 | return GenerateRecvPayload(variables);
27 | }
28 |
29 | return new Payload
30 | {
31 | Extensions = new Dictionary
32 | {
33 | ["hash"] = _queries[queryName],
34 | },
35 | QueryName = queryName,
36 | Variables = variables,
37 | };
38 | }
39 |
40 | private IReadOnlyCollection GenerateRecvPayload(IReadOnlyDictionary variables)
41 | {
42 | var payloads = new List
43 | {
44 | new()
45 | {
46 | Category = "poe/bot_response_speed",
47 | Data = variables,
48 | },
49 | };
50 |
51 | if (_random.NextDouble() > 0.9)
52 | {
53 | payloads.Add(new PayloadItem
54 | {
55 | Category = "poe/statsd_event",
56 | Data = new Dictionary
57 | {
58 | { "key", "poe.speed.web_vitals.INP" },
59 | { "value", _random.Next(100, 126) },
60 | { "category", "time" },
61 | { "path", "/[handle]" },
62 | { "extra_data", new Dictionary() },
63 | }
64 | });
65 | }
66 |
67 | return payloads;
68 | }
69 | }
--------------------------------------------------------------------------------
/src/libs/Poe/Poe.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | netstandard2.0;net4.6.2;net6.0;net7.0
5 | $(NoWarn);CA5394
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | A reverse engineered C# API wrapper for Quora's Poe, which provides free access to ChatGPT, GPT-4, and Claude.
14 | api;client;sdk;dotnet;swagger;openapi;specification;poe
15 |
16 |
17 |
18 |
19 | all
20 | runtime; build; native; contentfiles; analyzers; buildtransitive
21 |
22 |
23 | all
24 | runtime; build; native; contentfiles; analyzers; buildtransitive
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/src/libs/Poe/PoeApi.Authorization.cs:
--------------------------------------------------------------------------------
1 | using System.Net.Http.Headers;
2 | using System.Text;
3 |
4 | // ReSharper disable UnusedParameter.Local
5 | // ReSharper disable MemberCanBeMadeStatic.Local
6 |
7 | #pragma warning disable CA1822
8 |
9 | namespace Poe;
10 |
11 | public partial class PoeApi
12 | {
13 | private string ApiKey { get; } = string.Empty;
14 |
15 | private Task PrepareRequestAsync(HttpClient client, HttpRequestMessage request, string url, CancellationToken cancellationToken)
16 | {
17 | if (!string.IsNullOrWhiteSpace(ApiKey))
18 | {
19 | request.Headers.Authorization = new AuthenticationHeaderValue(
20 | scheme: "Bearer",
21 | parameter: ApiKey);
22 | }
23 |
24 | return Task.CompletedTask;
25 | }
26 |
27 | private Task PrepareRequestAsync(HttpClient client, HttpRequestMessage request, StringBuilder builder, CancellationToken cancellationToken)
28 | {
29 | return Task.CompletedTask;
30 | }
31 |
32 | private Task ProcessResponseAsync(HttpClient client, HttpResponseMessage message, CancellationToken cancellationToken)
33 | {
34 | return Task.CompletedTask;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/libs/Poe/PoeApi.Constructors.cs:
--------------------------------------------------------------------------------
1 | namespace Poe;
2 |
3 | ///
4 | /// Class providing methods for API access.
5 | ///
6 | public partial class PoeApi
7 | {
8 | ///
9 | /// Sets the selected apiKey as a default header for the HttpClient.
10 | ///
11 | ///
12 | ///
13 | public PoeApi(string apiKey, HttpClient httpClient)
14 | {
15 | ApiKey = apiKey ?? throw new ArgumentNullException(nameof(apiKey));
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/libs/Poe/PoeApi.cs:
--------------------------------------------------------------------------------
1 | // using System.Text.RegularExpressions;
2 | //
3 | // namespace Poe;
4 | //
5 | // ///
6 | // /// Class providing methods for API access.
7 | // ///
8 | // public partial class PoeApi
9 | // {
10 | // string gqlUrl = "https://poe.com/api/gql_POST";
11 | // string gqlRecvUrl = "https://poe.com/api/receive_POST";
12 | // string homeUrl = "https://poe.com";
13 | // string settingsUrl = "https://poe.com/api/settings";
14 | // bool wsConnecting = false;
15 | // bool wsConnected = false;
16 | // bool wsError = false;
17 | // int connectCount = 0;
18 | // int setupCount = 0;
19 | // string token;
20 | // string deviceId;
21 | // string proxy;
22 | // string clientIdentifier;
23 | // Dictionary activeMessages = new Dictionary();
24 | // Dictionary> messageQueues = new Dictionary>();
25 | // Dictionary> suggestionCallbacks = new Dictionary>();
26 | // Dictionary headers = new Dictionary()
27 | // {
28 | // {"User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"},
29 | // {"Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"},
30 | // {"Accept-Encoding", "gzip, deflate, br"},
31 | // {"Accept-Language", "en-US,en;q=0.9"},
32 | // {"Sec-Ch-Ua", "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"112\""},
33 | // {"Sec-Ch-Ua-Mobile", "?0"},
34 | // {"Sec-Ch-Ua-Platform", "\"Linux\""},
35 | // {"Upgrade-Insecure-Requests", "1"}
36 | // };
37 | // string formkeySalt = null;
38 | // string formkey = null;
39 | //
40 | // //... other fields
41 | //
42 | // public Client(string token, string proxy = null, string deviceId = null, string clientIdentifier = "chrome112", string formkey = null){
43 | // this.token = token;
44 | // this.deviceId = deviceId;
45 | // this.proxy = proxy;
46 | // this.clientIdentifier = clientIdentifier;
47 | // this.formkey = formkey;
48 | // ConnectWs();
49 | // }
50 | //
51 | // public void SetupSession(){
52 | // Console.WriteLine("Setting up session...");
53 | // // Here you would create a new instance of HttpClient and set its headers and cookies
54 | //
55 | // // Please note, you will need a separate library in order to handle proxies with HttpClient, such as HttpClientFactory
56 | // }
57 | //
58 | // public async Task RequestWithRetries(HttpMethod method, string requestUri, HttpContent content = null, int attempts = 10){
59 | // for (int i = 0; i < attempts; i++){
60 | // // Here would be the logic to execute the request and check its response status
61 | //
62 | // // When handling exceptions for failed requests, you will throw the appropriate HttpExceptions instead of RuntimeError
63 | // }
64 | // throw new Exception($"Failed to download {requestUri} too many times.");
65 | // }
66 | //
67 | // public async Task SendMessage(string chatbot, string message, bool withChatBreak = false,
68 | // int timeout = 20, bool asyncRecv = true, Action