mirror of
https://github.com/zhengkai/orca.git
synced 2026-02-04 17:02:26 +08:00
up
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash -ex
|
||||||
|
|
||||||
API_HOST="http://10.0.84.49:22035"
|
API_HOST="http://10.0.84.49:22035"
|
||||||
# API_HOST="http://localhost:22035"
|
# API_HOST="http://localhost:22035"
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ message Rsp {
|
|||||||
message RspUsage {
|
message RspUsage {
|
||||||
uint32 prompt_tokens = 1;
|
uint32 prompt_tokens = 1;
|
||||||
uint32 total_tokens = 2;
|
uint32 total_tokens = 2;
|
||||||
|
uint32 completion_tokens = 3;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Core) add(req *pb.Req, hr *http.Request) (pr *row) {
|
func (c *Core) add(req *pb.Req, hr *http.Request) (pr *row, cached bool) {
|
||||||
|
|
||||||
hash := req.Hash()
|
hash := req.Hash()
|
||||||
|
|
||||||
@@ -16,6 +16,7 @@ func (c *Core) add(req *pb.Req, hr *http.Request) (pr *row) {
|
|||||||
if ok {
|
if ok {
|
||||||
zj.F(`hit %x`, hash)
|
zj.F(`hit %x`, hash)
|
||||||
c.mux.Unlock()
|
c.mux.Unlock()
|
||||||
|
cached = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ func (c *Core) getAB(p *pb.Req, r *http.Request) (ab []byte, cached bool, err er
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pr := c.add(p, r)
|
pr, cached := c.add(p, r)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
reqFile := util.CacheName(p.Hash()) + `-req.json`
|
reqFile := util.CacheName(p.Hash()) + `-req.json`
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type DownloadFunc func(url string) (ab []byte, err error)
|
|||||||
|
|
||||||
// CacheName ...
|
// CacheName ...
|
||||||
func CacheName(hash [16]byte) string {
|
func CacheName(hash [16]byte) string {
|
||||||
s := fmt.Sprintf(`cache/%x/%x/%x`, hash[0:2], hash[2:4], hash[4:])
|
s := fmt.Sprintf(`cache/%02x/%02x/%02x/%x`, hash[0], hash[1], hash[2], hash[3:])
|
||||||
os.MkdirAll(StaticFile(filepath.Dir(s)), 0755)
|
os.MkdirAll(StaticFile(filepath.Dir(s)), 0755)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user