Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fe6acca652 | ||
|
49a60bef8d | ||
|
e8bb9f124f | ||
|
4b586b3860 |
@ -4,8 +4,6 @@
|
||||
|
||||
Yes, there is a lot of crappy copypasta html/css/js code. As long as it works! 🤷
|
||||
|
||||
This is a fork that looks to add postgres support as well as anthropic ai support.
|
||||
|
||||
# Features
|
||||
|
||||
* Written in Go:
|
||||
@ -24,7 +22,7 @@ This is a fork that looks to add postgres support as well as anthropic ai suppor
|
||||
To run this code locally, setup `go`, open this project and run this:
|
||||
|
||||
```bash
|
||||
go run cmd/flightlesssomething/main.go -data-dir data -discord-client-id xxxxxxxxxxxxxxxxxxx -discord-client-secret xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -discord-redirect-url 'http://127.0.0.1:8080/login/callback' -session-secret xxxxxxxxxxxxxxxxxxxxxxxx -openai-api-key xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
go run cmd/flightlesssomething/main.go -data-dir data -discord-client-id xxxxxxxxxxxxxxxxxxx -discord-client-secret xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -discord-redirect-url 'http://127.0.0.1:8080/login/callback' -session-secret xxxxxxxxxxxxxxxxxxxxxxxx
|
||||
```
|
||||
|
||||
Then open in browser: http://127.0.0.1:8080/
|
||||
|
@ -225,7 +225,7 @@ func postBenchmarkCreate(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if openaiClient != nil || anthroClient != nil {
|
||||
if openaiClient != nil {
|
||||
go generateSummary(&benchmark, csvFiles)
|
||||
}
|
||||
|
||||
|
15
config.go
15
config.go
@ -20,11 +20,6 @@ type Config struct {
|
||||
OpenAIApiKey string
|
||||
OpenAIModel string
|
||||
|
||||
AnthroAPIKey string
|
||||
AnthroModel string
|
||||
|
||||
DBurl string
|
||||
|
||||
Version bool
|
||||
}
|
||||
|
||||
@ -43,11 +38,6 @@ func NewConfig() (*Config, error) {
|
||||
flag.StringVar(&config.OpenAIModel, "openai-model", "gpt-4o", "OpenAI model ID")
|
||||
flag.StringVar(&config.OpenAIApiKey, "openai-api-key", "", "OpenAI API Key (leave empty to disable OpenAI integration)")
|
||||
|
||||
flag.StringVar(&config.AnthroAPIKey, "anthro-api-key", "", "Anthropic API Key (leave empty to disable Anthropic integration)")
|
||||
flag.StringVar(&config.AnthroModel, "anthro-model", "claude-3-haiku-20240307", "Anthropic model ID")
|
||||
|
||||
flag.StringVar(&config.DBurl, "db-url", "", "Database URL")
|
||||
|
||||
flag.BoolVar(&config.Version, "version", false, "prints version of the application")
|
||||
|
||||
envflag.Parse(envflag.WithPrefix("FS_"))
|
||||
@ -79,11 +69,6 @@ func NewConfig() (*Config, error) {
|
||||
return nil, errors.New("missing openai-url argument")
|
||||
}
|
||||
}
|
||||
if config.AnthroAPIKey != "" {
|
||||
if config.AnthroModel == "" {
|
||||
return nil, errors.New("missing anthro-model argument")
|
||||
}
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
14
go.mod
14
go.mod
@ -2,24 +2,12 @@ module flightlesssomething
|
||||
|
||||
go 1.22
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.10.0
|
||||
github.com/liushuangls/go-anthropic v1.6.0
|
||||
gorm.io/driver/postgres v1.4.1
|
||||
)
|
||||
require github.com/gin-gonic/gin v1.10.0
|
||||
|
||||
require (
|
||||
github.com/gorilla/context v1.1.2 // indirect
|
||||
github.com/gorilla/securecookie v1.1.2 // indirect
|
||||
github.com/gorilla/sessions v1.2.2 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.13.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgtype v1.12.0 // indirect
|
||||
github.com/jackc/pgx/v4 v4.17.2 // indirect
|
||||
github.com/wader/gormstore/v2 v2.0.3 // indirect
|
||||
)
|
||||
|
||||
|
12
go.sum
12
go.sum
@ -1,5 +1,4 @@
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||
@ -9,7 +8,6 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/
|
||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
@ -48,7 +46,6 @@ github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LB
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
@ -68,6 +65,7 @@ github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pw
|
||||
github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM=
|
||||
github.com/gorilla/sessions v1.2.2 h1:lqzMYz6bOfvn2WriPUjNByzeXIlVzURcPmgMczkmTjY=
|
||||
github.com/gorilla/sessions v1.2.2/go.mod h1:ePLdVu+jbEgHH+KWw8I1z2wqd0BAdAQh/8LRvBeoNcQ=
|
||||
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
|
||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||
@ -84,10 +82,10 @@ github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc=
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
|
||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||
@ -143,10 +141,6 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
|
||||
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/liushuangls/go-anthropic v1.6.0 h1:8hDEn/EJkeerOFwnQ10efTlRIU6VO+IxE6u6IinphBg=
|
||||
github.com/liushuangls/go-anthropic v1.6.0/go.mod h1:sUg9f/ZHoia6Nc8zoNvT7+KavHwMq2eL3VY1Mgf6I7Y=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
@ -165,7 +159,6 @@ github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjY
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
@ -182,7 +175,6 @@ github.com/sashabaranov/go-openai v1.28.0 h1:WS9F9BriSvtHvknPQy2Oi3b+8zkmJdEXcyc
|
||||
github.com/sashabaranov/go-openai v1.28.0/go.mod h1:lj5b/K+zjTSFxVLijLSTDZuP7adOgerWeFyZLUhAKRg=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
|
113
openai.go
113
openai.go
@ -2,7 +2,6 @@ package flightlesssomething
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"log"
|
||||
"math"
|
||||
"sort"
|
||||
@ -10,46 +9,20 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
anthro "github.com/liushuangls/go-anthropic"
|
||||
openai "github.com/sashabaranov/go-openai"
|
||||
)
|
||||
|
||||
const systemMessage = `
|
||||
You are given PC benchmark data of several runs. All this data is visible in the website in a form of charts and your goal is to provide insights.
|
||||
|
||||
Required format MUST be like this:
|
||||
# Top runs:
|
||||
* **Highest FPS**: Run 1 and comment
|
||||
* **Smoothest FPS**: Run 2 and comment
|
||||
* **Best overall**: Run 3 and comment
|
||||
# Issues:
|
||||
* ...
|
||||
* ...
|
||||
* ...
|
||||
# Summary
|
||||
...
|
||||
|
||||
You MUST:
|
||||
* "Top runs" section is needed ONLY if there are 2 runs or more.
|
||||
* In "Top runs" sections, label names must use in-line code syntax.
|
||||
* In Issues section, Figure out if any of the run is significantly worse then others in the same benchmark. You MUST use ONLY the data provided to explain the difference, and your points must be based only on the data provided. If there are no issues - do NOT write this section. Do not make any guesses. Additional requirements: (a) validate if the same hardware/software was used (by using provided text fields, NOT the data), (b) do not speculate, but use numbers to back up your claims, (c) only write if it's an actual issue with FPS (everything else is just additional information).
|
||||
* In Top runs section, provide which run has the (average) "Highest FPS", which has the "Smoothest FPS" (LOWEST std.dev. and variance of FPS value - LOWEST, NOT HIGHEST) and which is the best "Best overall" (preferrably lower std.dev./variance than higher FPS, but if slight decrease in stability gives significantly higher FPS - pick that one). NEVER consider runs that have significantly lower FPS or has other significant issues. Exclude runs from consideration if they are significantly worse than the rest (as it would be mentioned in issues section). Note that your goal is to pick winners and not do a comparison in this section. Include numbers to justify your claims.
|
||||
* In Summary section, provide an overview/summary of this benchmark in only one paragraph and in natural language. In this section, use your deep understanding of context of what is actually being compared (driver versions? Different configurations? Different settings? different schedulers? Different OS? Focus on that) and comment on that.
|
||||
* First 2 sections should be bullet points, no subpoints, only 1 bullet point per point, while summary should be a single paragraph.
|
||||
* NEVER use actual numbers. Instead, use percentage in comparison to other runs.
|
||||
|
||||
Your data does not contain anything about scx schedulers, but some benchmarks might compare these:
|
||||
* sched_ext is a Linux kernel feature which enables implementing kernel thread schedulers in BPF and dynamically loading them. This repository contains various scheduler implementations and support utilities.
|
||||
* sched_ext enables safe and rapid iterations of scheduler implementations, thus radically widening the scope of scheduling strategies that can be experimented with and deployed; even in massive and complex production environments.
|
||||
* Available scx schedulers (at the time of writting): scx_asdf scx_bpfland scx_central scx_lavd scx_layered scx_nest scx_qmap scx_rlfifo scx_rustland scx_rusty scx_simple scx_userland
|
||||
|
||||
Additional RULES THAT YOU MUST STRICTLY FOLLOW:
|
||||
1. In summary and issues sections, you are STRICTLY FORBIDDEN TO REFER TO ANY RUN BY IT'S LABEL NAME. Instead, you must use context and deep understand what what is being compared, and refer to each run by it's context, rather than title.
|
||||
2. In summary section, any technical terms or codes are easier to read when encapsulated with in-code syntax.
|
||||
3. In summary section, never refer to runs as "first run" or "second run". Refer to them by their context.
|
||||
4. In issues section, NEVER write "has no issues" kind of statements.
|
||||
5. In issues section, NEVER write anything that is not DIRECTLY related to issue with either FPS or Frametime.
|
||||
6. In issues section, additionally point out if configuration is different that isn't directly part of benchmark comparison (e.g. comparing schedulers, but cpu or OS is different)
|
||||
1. Write at max 3 sections (headers) - "Top runs", "Issues" (optional) and "Summary".
|
||||
2. In Issues section, Figure out if any of the run is significantly worse then others in the same benchmark. You MUST use ONLY the data provided to explain the difference, and your points must be based only on the data provided. If there are no issues - do not write this section. Do not make any guesses. Additional requirements: (a) validate if the same hardware/software was used (by using provided text fields, NOT the data), (b) do not speculate, but use numbers to back up your claims, (c) only write if it's an actual issue with FPS (everything else is just additional information).
|
||||
3. In Top runs section, provide which run has the (average) "Highest FPS", which has the "Smoothest FPS" (LOWEST std.dev. and variance of FPS value - LOWEST, NOT HIGHEST) and which is the best "Best overall" (preferrably lower std.dev./variance than higher FPS, but if slight decrease in stability gives significantly higher FPS - pick that one). NEVER consider runs that have significantly lower FPS or has other significant issues. Exclude runs from consideration if they are significantly worse than the rest (as it would be mentioned in issues section). Note that your goal is to pick winners and not do a comparison in this section. Include numbers to justify your claims.
|
||||
4. In Summary section, provide an overview of all runs. Mention which runs are similar and which are different. Mention which runs are better in terms of FPS and which are better in terms of stability. Mention if there are any issues and what could be the reason for them. In short - summarize whole benchmark.
|
||||
5. First 2 sections should be bullet points, no subpoints, only 1 bullet point per point, while summary should be a single paragraph.
|
||||
6. NEVER use actual numbers. Instead, use percentage in comparison to other runs.
|
||||
7. Use markdown, use code syntax for labels.
|
||||
`
|
||||
|
||||
var (
|
||||
@ -59,7 +32,7 @@ var (
|
||||
|
||||
func generateSummary(b *Benchmark, bds []*BenchmarkData) {
|
||||
// Check if OpenAI integration is not enabled
|
||||
if openaiClient == nil && anthroClient == nil {
|
||||
if openaiClient == nil {
|
||||
return
|
||||
}
|
||||
|
||||
@ -78,13 +51,23 @@ func generateSummary(b *Benchmark, bds []*BenchmarkData) {
|
||||
userPrompt := writeAIPrompt(bds, b.Title, b.Description)
|
||||
|
||||
// Retrieve AI response
|
||||
resp, err := getAIResponse(systemMessage, userPrompt)
|
||||
resp, err := openaiClient.CreateChatCompletion(
|
||||
context.Background(),
|
||||
openai.ChatCompletionRequest{
|
||||
Model: openaiModel,
|
||||
Temperature: 0.0,
|
||||
Messages: []openai.ChatCompletionMessage{
|
||||
{Role: openai.ChatMessageRoleSystem, Content: systemMessage},
|
||||
{Role: openai.ChatMessageRoleUser, Content: userPrompt},
|
||||
},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
log.Println("Failed to generate AI summary:", err)
|
||||
return
|
||||
}
|
||||
|
||||
db.Model(&Benchmark{}).Where("id = ?", b.ID).Update("AiSummary", resp)
|
||||
db.Model(&Benchmark{}).Where("id = ?", b.ID).Update("AiSummary", resp.Choices[0].Message.Content)
|
||||
|
||||
// Update status
|
||||
inProgressSummariesMux.Lock()
|
||||
@ -92,40 +75,6 @@ func generateSummary(b *Benchmark, bds []*BenchmarkData) {
|
||||
inProgressSummariesMux.Unlock()
|
||||
}
|
||||
|
||||
func getAIResponse(systemMessage string, userPrompt string) (string, error) {
|
||||
if openaiClient != nil {
|
||||
resp, err := openaiClient.CreateChatCompletion(
|
||||
context.Background(),
|
||||
openai.ChatCompletionRequest{
|
||||
Model: openaiModel,
|
||||
Temperature: 0.0,
|
||||
Messages: []openai.ChatCompletionMessage{
|
||||
{Role: openai.ChatMessageRoleSystem, Content: systemMessage},
|
||||
{Role: openai.ChatMessageRoleUser, Content: userPrompt},
|
||||
},
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resp.Choices[0].Message.Content, nil
|
||||
} else if anthroClient != nil {
|
||||
resp, err := anthroClient.CreateMessages(context.Background(), anthro.MessagesRequest{
|
||||
Model: anthroModel,
|
||||
System: systemMessage,
|
||||
MaxTokens: 1024,
|
||||
Messages: []anthro.Message{
|
||||
anthro.NewUserTextMessage(userPrompt),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return resp.Content[0].Text, nil
|
||||
}
|
||||
return "", errors.New("no AI client configured")
|
||||
}
|
||||
|
||||
func writeAIPrompt(bds []*BenchmarkData, bdTitle, bdDescription string) string {
|
||||
sb := strings.Builder{}
|
||||
sb.WriteString("Benchmark title: ")
|
||||
@ -240,10 +189,12 @@ func writeAIPrompt(bds []*BenchmarkData, bdTitle, bdDescription string) string {
|
||||
|
||||
type AIPromptArrayStats struct {
|
||||
Count int
|
||||
Lowest float64
|
||||
Low1Percent float64
|
||||
Mean float64
|
||||
Median float64
|
||||
Top97Percent float64
|
||||
Highest float64
|
||||
StdDev float64
|
||||
Variance float64
|
||||
}
|
||||
@ -255,6 +206,8 @@ func calculateAIPromptArrayStats(data []float64) AIPromptArrayStats {
|
||||
|
||||
sort.Float64s(data)
|
||||
count := len(data)
|
||||
lowest := data[0]
|
||||
highest := data[count-1]
|
||||
|
||||
low1PercentIndex := int(math.Ceil(0.01*float64(count))) - 1
|
||||
if low1PercentIndex < 0 {
|
||||
@ -291,10 +244,12 @@ func calculateAIPromptArrayStats(data []float64) AIPromptArrayStats {
|
||||
|
||||
return AIPromptArrayStats{
|
||||
Count: count,
|
||||
Lowest: lowest,
|
||||
Low1Percent: low1Percent,
|
||||
Mean: mean,
|
||||
Median: median,
|
||||
Top97Percent: top97Percent,
|
||||
Highest: highest,
|
||||
StdDev: stdDev,
|
||||
Variance: variance,
|
||||
}
|
||||
@ -302,12 +257,14 @@ func calculateAIPromptArrayStats(data []float64) AIPromptArrayStats {
|
||||
|
||||
func (as AIPromptArrayStats) String() string {
|
||||
return strings.Join([]string{
|
||||
"Count:" + strconv.Itoa(as.Count),
|
||||
"Low1Percent:" + strconv.FormatFloat(as.Low1Percent, 'f', -1, 64),
|
||||
"Mean:" + strconv.FormatFloat(as.Mean, 'f', -1, 64),
|
||||
"Median:" + strconv.FormatFloat(as.Median, 'f', -1, 64),
|
||||
"Top97Percent:" + strconv.FormatFloat(as.Top97Percent, 'f', -1, 64),
|
||||
"StdDev:" + strconv.FormatFloat(as.StdDev, 'f', -1, 64),
|
||||
"Variance:" + strconv.FormatFloat(as.Variance, 'f', -1, 64),
|
||||
"Count: " + strconv.Itoa(as.Count),
|
||||
"Lowest: " + strconv.FormatFloat(as.Lowest, 'f', -1, 64),
|
||||
"Low1Percent: " + strconv.FormatFloat(as.Low1Percent, 'f', -1, 64),
|
||||
"Mean: " + strconv.FormatFloat(as.Mean, 'f', -1, 64),
|
||||
"Median: " + strconv.FormatFloat(as.Median, 'f', -1, 64),
|
||||
"Top97Percent: " + strconv.FormatFloat(as.Top97Percent, 'f', -1, 64),
|
||||
"Highest: " + strconv.FormatFloat(as.Highest, 'f', -1, 64),
|
||||
"StdDev: " + strconv.FormatFloat(as.StdDev, 'f', -1, 64),
|
||||
"Variance: " + strconv.FormatFloat(as.Variance, 'f', -1, 64),
|
||||
}, ", ")
|
||||
}
|
||||
|
21
server.go
21
server.go
@ -14,11 +14,9 @@ import (
|
||||
gormsessions "github.com/gin-contrib/sessions/gorm"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/glebarez/sqlite"
|
||||
anthro "github.com/liushuangls/go-anthropic"
|
||||
"github.com/ravener/discord-oauth2"
|
||||
openai "github.com/sashabaranov/go-openai"
|
||||
"golang.org/x/oauth2"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
@ -35,9 +33,6 @@ var (
|
||||
// OpenAI
|
||||
openaiClient *openai.Client
|
||||
openaiModel string
|
||||
|
||||
anthroClient *anthro.Client
|
||||
anthroModel string
|
||||
)
|
||||
|
||||
func Start(c *Config, version string) {
|
||||
@ -50,13 +45,6 @@ func Start(c *Config, version string) {
|
||||
openaiModel = c.OpenAIModel
|
||||
}
|
||||
|
||||
// Setup Anthro client //
|
||||
|
||||
if c.AnthroAPIKey != "" {
|
||||
anthroClient = anthro.NewClient(c.AnthroAPIKey)
|
||||
anthroModel = c.AnthroModel
|
||||
}
|
||||
|
||||
// Setup data dir //
|
||||
|
||||
_, err := os.Stat(c.DataDir)
|
||||
@ -92,14 +80,7 @@ func Start(c *Config, version string) {
|
||||
|
||||
// Setup gorm (database) //
|
||||
|
||||
var gormDialector gorm.Dialector
|
||||
if c.DBurl != "" {
|
||||
gormDialector = postgres.Open(c.DBurl)
|
||||
} else {
|
||||
gormDialector = sqlite.Open(filepath.Join(c.DataDir, "database.db"))
|
||||
}
|
||||
|
||||
db, err = gorm.Open(gormDialector, &gorm.Config{})
|
||||
db, err = gorm.Open(sqlite.Open(filepath.Join(c.DataDir, "database.db")), &gorm.Config{})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
// Common chart options
|
||||
const commonChartOptions = {
|
||||
chart: {backgroundColor: null, style: {color: '#FFFFFF'}, animation: false, boost: {useGPUTranslations: true, usePreallocated: true}},
|
||||
chart: {backgroundColor: null, style: {color: '#FFFFFF'}, animation: false},
|
||||
title: {style: {color: '#FFFFFF', fontSize: '16px'}},
|
||||
subtitle: {style: {color: '#FFFFFF', fontSize: '12px'}},
|
||||
xAxis: {labels: {style: {color: '#FFFFFF'}}, lineColor: '#FFFFFF', tickColor: '#FFFFFF'},
|
||||
@ -100,8 +100,8 @@ function createBarChart(chartId, title, unit, categories, data, colors, maxY = n
|
||||
}
|
||||
|
||||
// Create bar charts for average CPU, GPU, GPU Core clock and GPU memory clock load
|
||||
createBarChart('fpsSummaryChart', 'Average FPS', 'fps', fpsDataArrays.map(dataArray => dataArray.label), fpsAverages, colors);
|
||||
createBarChart('frametimeSummaryChart', 'Average Frametime', 'ms', frameTimeDataArrays.map(dataArray => dataArray.label), frametimeAverages, colors);
|
||||
createBarChart('fpsSummaryChart', 'Average FPS', 'fps', fpsDataArrays.map(dataArray => dataArray.label), fpsAverages, colors, 100);
|
||||
createBarChart('frametimeSummaryChart', 'Average Frametime', 'ms', frameTimeDataArrays.map(dataArray => dataArray.label), frametimeAverages, colors, 100);
|
||||
createBarChart('cpuLoadSummaryChart', 'Average CPU Load', '%', cpuLoadDataArrays.map(dataArray => dataArray.label), cpuLoadAverages, colors, 100);
|
||||
createBarChart('gpuLoadSummaryChart', 'Average GPU Load', '%', gpuLoadDataArrays.map(dataArray => dataArray.label), gpuLoadAverages, colors, 100);
|
||||
createBarChart('gpuCoreClockSummaryChart', 'Average GPU Core Clock', 'Hz', gpuCoreClockDataArrays.map(dataArray => dataArray.label), gpuCoreClockAverages, colors);
|
||||
|
Loading…
Reference in New Issue
Block a user