-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed some failing jigsawstack funcs and added some tests to prevent …
…regressions
- Loading branch information
1 parent
9a549d1
commit 1baaa92
Showing
12 changed files
with
197 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package jigsawstack_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/conneroisu/groq-go/extensions/jigsawstack" | ||
"github.com/conneroisu/groq-go/pkg/test" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestJigsawStack_PromptCreate(t *testing.T) { | ||
if !test.IsIntegrationTest() { | ||
t.Skip("Skipping integration test") | ||
} | ||
a := assert.New(t) | ||
apiKey, err := test.GetAPIKey("JIGSAWSTACK_API_KEY") | ||
a.NoError(err) | ||
j, err := jigsawstack.NewJigsawStack(apiKey) | ||
a.NoError(err) | ||
resp, err := j.PromptCreate(context.Background(), jigsawstack.PromptCreateRequest{ | ||
Prompt: ` | ||
Check warning on line 22 in extensions/jigsawstack/prompt_test.go Codeac.io / Codeac Code QualityCodeDuplication
|
||
You are a helpful assistant that answers questions based on the provided context. | ||
Your job is to provide code completions based on the provided context. | ||
`, | ||
Inputs: []jigsawstack.PromptCreateInput{ | ||
{ | ||
Key: "context", | ||
Optional: false, | ||
InitialValue: ` | ||
<file name="context.py"> | ||
def main(): | ||
print("Hello, World!") | ||
if __name__ == "__main__": | ||
main() | ||
</file> | ||
`, | ||
}, | ||
}, | ||
}) | ||
a.NoError(err) | ||
t.Logf("response: %v", resp) | ||
t.Fail() | ||
} | ||
func TestJigsawStack_PromptGet(t *testing.T) { | ||
if !test.IsIntegrationTest() { | ||
t.Skip("Skipping integration test") | ||
} | ||
a := assert.New(t) | ||
apiKey, err := test.GetAPIKey("JIGSAWSTACK_API_KEY") | ||
a.NoError(err) | ||
j, err := jigsawstack.NewJigsawStack(apiKey) | ||
a.NoError(err) | ||
resp, err := j.PromptGet(context.Background(), "test") | ||
a.NoError(err) | ||
a.NotEmpty(resp.Prompt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package jigsawstack_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/conneroisu/groq-go/extensions/jigsawstack" | ||
"github.com/conneroisu/groq-go/pkg/test" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestJigsawStack_TextToSQL tests the TextToSQL method of the JigsawStack client. | ||
func TestJigsawStack_TextToSQL(t *testing.T) { | ||
if !test.IsIntegrationTest() { | ||
t.Skip("Skipping unit test") | ||
} | ||
a := assert.New(t) | ||
ctx := context.Background() | ||
apiKey, err := test.GetAPIKey("JIGSAWSTACK_API_KEY") | ||
a.NoError(err) | ||
j, err := jigsawstack.NewJigsawStack(apiKey) | ||
a.NoError(err) | ||
resp, err := j.TextToSQL(ctx, "select all users", ` | ||
CREATE TABLE users ( | ||
id INT PRIMARY KEY, | ||
name VARCHAR(255), | ||
email VARCHAR(255), | ||
age INT | ||
); | ||
`) | ||
a.NoError(err) | ||
a.NotEmpty(resp.SQL) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package jigsawstack_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/conneroisu/groq-go/extensions/jigsawstack" | ||
"github.com/conneroisu/groq-go/pkg/test" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestJigsawStack_FileAdd tests the FileAdd method of the JigsawStack client. | ||
func TestJigsawStack_FileAdd(t *testing.T) { | ||
if !test.IsIntegrationTest() { | ||
t.Skip("Skipping unit test") | ||
} | ||
a := assert.New(t) | ||
ctx := context.Background() | ||
apiKey, err := test.GetAPIKey("JIGSAWSTACK_API_KEY") | ||
a.NoError(err) | ||
j, err := jigsawstack.NewJigsawStack(apiKey) | ||
a.NoError(err) | ||
resp, err := j.FileAdd(ctx, "test", "text/plain", "hello world") | ||
a.NoError(err) | ||
a.NotEmpty(resp) | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package jigsawstack_test | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/conneroisu/groq-go/extensions/jigsawstack" | ||
"github.com/conneroisu/groq-go/pkg/test" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// TestJigsawStack_WebSearch tests the WebSearch method of the JigsawStack client. | ||
func TestJigsawStack_WebSearch(t *testing.T) { | ||
if !test.IsIntegrationTest() { | ||
t.Skip("Skipping unit test") | ||
} | ||
a := assert.New(t) | ||
ctx := context.Background() | ||
apiKey, err := test.GetAPIKey("JIGSAWSTACK_API_KEY") | ||
a.NoError(err) | ||
j, err := jigsawstack.NewJigsawStack(apiKey) | ||
a.NoError(err) | ||
resp, err := j.WebSearch(ctx, "hello world golang") | ||
a.NoError(err) | ||
Check warning on line 24 in extensions/jigsawstack/web_test.go Codeac.io / Codeac Code QualityCodeDuplication
Check warning on line 24 in extensions/jigsawstack/web_test.go Codeac.io / Codeac Code QualityCodeDuplication
|
||
a.NotEmpty(resp.Results) | ||
} | ||
|
||
// TestJigsawStack_WebSearchSuggestions tests the WebSearchSuggestions method of the JigsawStack client. | ||
func TestJigsawStack_WebSearchSuggestions(t *testing.T) { | ||
if !test.IsIntegrationTest() { | ||
t.Skip("Skipping unit test") | ||
} | ||
a := assert.New(t) | ||
ctx := context.Background() | ||
apiKey, err := test.GetAPIKey("JIGSAWSTACK_API_KEY") | ||
a.NoError(err) | ||
j, err := jigsawstack.NewJigsawStack(apiKey) | ||
a.NoError(err) | ||
resp, err := j.WebSearchSuggestions(ctx, "hello") | ||
a.NoError(err) | ||
a.NotEmpty(resp.Suggestions) | ||
} |