-
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.
- Loading branch information
Showing
4 changed files
with
90 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Go test binaries | ||
*.test | ||
*.exe | ||
*.pyc | ||
runme.sh | ||
|
||
# Environment stuff | ||
env | ||
venv | ||
.env | ||
.venv | ||
|
||
# OSX trash | ||
.DS_Store | ||
|
||
# Developers can store local stuff in dirs named __something | ||
__* | ||
|
||
# Files generated by JetBrains IDEs, e.g. IntelliJ IDEA | ||
.idea/ | ||
*.iml | ||
|
||
# Vscode files | ||
.vscode | ||
|
||
# This is where the result of the go build goes | ||
/output*/ | ||
/_output*/ | ||
/_output | ||
|
||
# Emacs save files | ||
*~ | ||
\#*\# | ||
.\#* | ||
|
||
# Vim-related files | ||
[._]*.s[a-w][a-z] | ||
[._]s[a-w][a-z] | ||
*.un~ | ||
Session.vim | ||
.netrwhist | ||
|
||
|
||
|
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,17 @@ | ||
# Examples | ||
View the examples to get a feel for how to use Tavily | ||
|
||
### Usage | ||
First, you'll have to add your API key to the code or to your environment with | ||
``` | ||
export TAVILY_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
``` | ||
or on Windows | ||
```ps1 | ||
set TAVILY_API_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | ||
``` | ||
Make sure to use your real API key and not a bunch of `X` characters. | ||
Then, switch into any directory and run `go run main.go` | ||
|
||
### Options | ||
- qna - Example question and answer response |
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,25 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/lwileczek/tavily" | ||
) | ||
|
||
func main() { | ||
API_KEY := os.Getenv("TAVILY_API_KEY") | ||
client, err := tavily.NewClient(API_KEY) | ||
if err != nil { | ||
fmt.Println("Oops must have forgot my API key!", err) | ||
return | ||
} | ||
|
||
answer, err := client.QASearch("Where does Messi play right now?") | ||
if err != nil { | ||
fmt.Println("Unable to get an answer for that, sorry", err) | ||
return | ||
} | ||
|
||
fmt.Println(answer) | ||
} |