-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from devalexandre/feat/add-examples
Feat/add examples
- Loading branch information
Showing
34 changed files
with
15,761 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
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,41 @@ | ||
# Website | ||
|
||
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
### Deployment | ||
|
||
Using SSH: | ||
|
||
``` | ||
$ USE_SSH=true yarn deploy | ||
``` | ||
|
||
Not using SSH: | ||
|
||
``` | ||
$ GIT_USER=<Your GitHub username> yarn deploy | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. |
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,3 @@ | ||
module.exports = { | ||
presets: [require.resolve('@docusaurus/core/lib/babel/preset')], | ||
}; |
Binary file added
BIN
+93.9 KB
...integrating-llms-and-ai-tools-in-go-applications/docusaurus-plushie-banner.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions
127
...024-06-18-langsmithgo-integrating-llms-and-ai-tools-in-go-applications/index.md
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,127 @@ | ||
--- | ||
slug: langsmithgo-integrating-llms-and-ai-tools-in-go-applications | ||
title: "LangsmithGo: Integrating LLMs and AI Tools in Go Applications" | ||
authors: [alexandre] | ||
tags: [news] | ||
--- | ||
|
||
# LangsmithGo: Integrating LLMs and AI Tools in Go Applications | ||
|
||
## Introduction | ||
|
||
Welcome to the official LangsmithGo project blog! Today, we will explore what LangsmithGo is, its benefits, and how it can be used to integrate language models (LLMs) and artificial intelligence (AI) tools into your Go applications. If you are a Go developer interested in AI, this article is for you. | ||
|
||
## What is Langsmith? | ||
|
||
Langsmith is a powerful platform designed to facilitate the integration of language models and AI tools into various applications. It offers a robust API that allows developers to create, manage, and monitor runs of language models, as well as support the addition of metadata, tools, and events. With Langsmith, you can leverage the potential of LLMs such as GPT-3 and GPT-3.5-turbo, among others, in your software solutions. | ||
|
||
## LangsmithGo: The Go Library for Langsmith | ||
|
||
LangsmithGo is the Go library that allows you to interact with the Langsmith API in a simple and efficient manner. It abstracts the complexities of communicating with the API, offering easy-to-use methods for creating and managing runs of LLMs and AI tools. With LangsmithGo, Go developers can quickly integrate advanced natural language processing capabilities into their applications. | ||
|
||
## Benefits of LangsmithGo | ||
|
||
1. Simple Integration: LangsmithGo offers an easy-to-use interface to integrate LLMs into Go applications. | ||
2. Flexibility: Supports various types of runs, including LLMs, tools, execution chains, and more. | ||
3. Monitoring and Management: Allows adding metadata, tools, and events to runs, facilitating monitoring and management. | ||
4. OpenAI Compatibility: Native support for OpenAI models, such as GPT-3 and GPT-3.5-turbo. | ||
|
||
## How to Use LangsmithGo | ||
|
||
Let's explore some practical examples of how to use LangsmithGo to create and manage runs of LLMs and AI tools. | ||
|
||
### Installation | ||
|
||
```sh | ||
go get github.com/tmc/langsmithgo | ||
``` | ||
|
||
### Configuration | ||
|
||
```go | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func init() { | ||
os.Setenv("LANGSMITH_API_KEY", "your_api_key_here") | ||
os.Setenv("LANGSMITH_PROJECT_NAME", "your_project_name_here") | ||
} | ||
|
||
``` | ||
|
||
### Creating an LLM Run | ||
|
||
Here is an example of how to create an LLM run with LangsmithGo: | ||
|
||
```go | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
|
||
"github.com/google/uuid" | ||
"github.com/tmc/langchaingo/llms" | ||
"github.com/tmc/langchaingo/llms/openai" | ||
"github.com/tmc/langsmithgo" | ||
) | ||
|
||
func main() { | ||
client, err := langsmithgo.NewClient() | ||
if err != nil { | ||
log.Fatalf("Error creating client: %v", err) | ||
} | ||
|
||
llm, err := openai.New() | ||
if err != nil { | ||
log.Fatalf("Error creating LLM: %v", err) | ||
} | ||
|
||
runId := uuid.New().String() | ||
prompt := "The first man to walk on the moon" | ||
ctx := context.Background() | ||
|
||
err = client.Run(&langsmithgo.RunPayload{ | ||
RunID: runId, | ||
Name: "example-llm-run", | ||
SessionName: "example-session", | ||
RunType: langsmithgo.LLM, | ||
Inputs: map[string]interface{}{ | ||
"prompt": prompt, | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("Error running: %v", err) | ||
} | ||
|
||
completion, err := llms.GenerateFromSinglePrompt(ctx, llm, prompt) | ||
if err != nil { | ||
log.Fatalf("Error generating completion: %v", err) | ||
} | ||
|
||
err = client.Run(&langsmithgo.RunPayload{ | ||
RunID: runId, | ||
Outputs: map[string]interface{}{ | ||
"output": completion, | ||
}, | ||
}) | ||
|
||
if err != nil { | ||
log.Fatalf("Error running: %v", err) | ||
} | ||
|
||
fmt.Println(completion) | ||
} | ||
|
||
``` | ||
|
||
## Conclusion | ||
|
||
LangsmithGo is a powerful tool for Go developers who want to integrate language models and AI tools into their applications. With its simple and flexible interface, you can quickly start creating, managing, and monitoring runs of LLMs, enriched with metadata, tools, and events. Try LangsmithGo today and elevate your Go applications to the next level! | ||
|
||
Follow our blog for more tutorials, examples, and updates on LangsmithGo. If you have any questions or suggestions, feel free to contact us. Happy coding! |
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,5 @@ | ||
alexandre: | ||
name: Alexandre Evangelista de Souza | ||
title: Maintainer of LangSmithGo | ||
url: https://github.com/devalexandre | ||
image_url: https://github.com/devalexandre.png |
Oops, something went wrong.