mirror of
https://github.com/coalaura/whiskr.git
synced 2025-09-08 00:29:54 +00:00
include exa cost
This commit is contained in:
11
chat.go
11
chat.go
@@ -14,11 +14,12 @@ import (
|
||||
)
|
||||
|
||||
type ToolCall struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Args string `json:"args"`
|
||||
Result string `json:"result,omitempty"`
|
||||
Done bool `json:"done,omitempty"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Args string `json:"args"`
|
||||
Result string `json:"result,omitempty"`
|
||||
Done bool `json:"done,omitempty"`
|
||||
Cost float64 `json:"cost,omitempty"`
|
||||
}
|
||||
|
||||
type TextFile struct {
|
||||
|
5
exa.go
5
exa.go
@@ -18,9 +18,14 @@ type ExaResult struct {
|
||||
Summary string `json:"summary"`
|
||||
}
|
||||
|
||||
type ExaCost struct {
|
||||
Total float64 `json:"total"`
|
||||
}
|
||||
|
||||
type ExaResults struct {
|
||||
RequestID string `json:"requestId"`
|
||||
Results []ExaResult `json:"results"`
|
||||
Cost ExaCost `json:"costDollars"`
|
||||
}
|
||||
|
||||
func (e *ExaResult) String() string {
|
||||
|
@@ -116,6 +116,8 @@ func HandleSearchWebTool(ctx context.Context, tool *ToolCall) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
tool.Cost = results.Cost.Total
|
||||
|
||||
if len(results.Results) == 0 {
|
||||
tool.Result = "error: no search results"
|
||||
|
||||
@@ -146,6 +148,8 @@ func HandleFetchContentsTool(ctx context.Context, tool *ToolCall) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
tool.Cost = results.Cost.Total
|
||||
|
||||
if len(results.Results) == 0 {
|
||||
tool.Result = "error: no search results"
|
||||
|
||||
|
@@ -407,16 +407,6 @@
|
||||
#updateToolHeight() {
|
||||
const result = this.#_tool.querySelector(".result");
|
||||
|
||||
try {
|
||||
const clone = result.cloneNode();
|
||||
|
||||
setTimeout(() => {
|
||||
console.log(clone, clone.getBoundingClientRect(), clone.scrollHeight, clone.height);
|
||||
}, 0);
|
||||
} catch(err) {
|
||||
console.warn(err);
|
||||
}
|
||||
|
||||
this.#_tool.style.setProperty("--height", `${result.scrollHeight}px`);
|
||||
}
|
||||
|
||||
@@ -1047,6 +1037,8 @@
|
||||
message.setTool(chunk.text);
|
||||
|
||||
if (chunk.text.done) {
|
||||
totalCost += chunk.text.cost || 0;
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user