Skip to content

Commit 5f856b7

Browse files
authored
Merge pull request #30 from petal-labs/fix/perplexity-tool-format
fix(providers): update Perplexity tool format to flat structure
2 parents 5227c4b + 8a7f979 commit 5f856b7

3 files changed

Lines changed: 13 additions & 18 deletions

File tree

providers/perplexity/mapping.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,10 @@ func mapTools(irisTools []core.Tool) []perplexityTool {
4747
}
4848

4949
result[i] = perplexityTool{
50-
Type: "function",
51-
Function: perplexityFunction{
52-
Name: t.Name(),
53-
Description: t.Description(),
54-
Parameters: params,
55-
},
50+
Type: "function",
51+
Name: t.Name(),
52+
Description: t.Description(),
53+
Parameters: params,
5654
}
5755
}
5856
return result

providers/perplexity/mapping_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ func TestMapTools(t *testing.T) {
6868
if result[0].Type != "function" {
6969
t.Errorf("result[0].Type = %q, want %q", result[0].Type, "function")
7070
}
71-
if result[0].Function.Name != "get_weather" {
72-
t.Errorf("result[0].Function.Name = %q, want %q", result[0].Function.Name, "get_weather")
71+
if result[0].Name != "get_weather" {
72+
t.Errorf("result[0].Name = %q, want %q", result[0].Name, "get_weather")
7373
}
74-
if result[0].Function.Description != "Get weather for a city" {
75-
t.Errorf("result[0].Function.Description = %q, want %q", result[0].Function.Description, "Get weather for a city")
74+
if result[0].Description != "Get weather for a city" {
75+
t.Errorf("result[0].Description = %q, want %q", result[0].Description, "Get weather for a city")
7676
}
7777

78-
if result[1].Function.Name != "search" {
79-
t.Errorf("result[1].Function.Name = %q, want %q", result[1].Function.Name, "search")
78+
if result[1].Name != "search" {
79+
t.Errorf("result[1].Name = %q, want %q", result[1].Name, "search")
8080
}
8181
})
8282
}

providers/perplexity/types.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,10 @@ type perplexityMessage struct {
5555
}
5656

5757
// perplexityTool represents a tool definition in the Perplexity format.
58+
// Perplexity uses a flat structure with name, description, and parameters
59+
// at the same level as type (not nested inside a "function" wrapper).
5860
type perplexityTool struct {
59-
Type string `json:"type"`
60-
Function perplexityFunction `json:"function"`
61-
}
62-
63-
// perplexityFunction represents a function definition for Perplexity tools.
64-
type perplexityFunction struct {
61+
Type string `json:"type"`
6562
Name string `json:"name"`
6663
Description string `json:"description"`
6764
Parameters json.RawMessage `json:"parameters"`

0 commit comments

Comments
 (0)