From d3a4179c0e76b8b11ba2956613fd7d1715e43936 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Mon, 22 Jan 2024 19:19:27 +0100 Subject: [PATCH] chore: README --- CODE_OF_CONDUCT.md | 128 ++++++++++++++++++++++++++++ CONTRIBUTING.md | 14 ++++ README.md | 204 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..50e4841 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +- Demonstrating empathy and kindness toward other people +- Being respectful of differing opinions, viewpoints, and experiences +- Giving and gracefully accepting constructive feedback +- Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +- Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +- The use of sexualized language or imagery, and sexual attention or + advances of any kind +- Trolling, insulting or derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or email + address, without their explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +support@traceloop.dev. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..5f43dca --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,14 @@ +# Contributing to OpenLLMetry-JS + +Thanks for taking the time to contribute! ๐Ÿ˜ƒ ๐Ÿš€ + +Please refer to our [Contributing Guide](https://traceloop.com/docs/openllmetry/contributing/overview) for instructions on how to contribute. + +## Releasing + +To release a new version of the package, run (make sure you have access to the `@traceloop` npm organization): + +```bash +nx run-many --targets=build +npx lerna publish --no-private +``` diff --git a/README.md b/README.md index 386b80f..0055ebb 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,202 @@ -# go-openllmetry -Sister project to OpenLLMetry, but in Go. Open-source observability for your LLM application, based on OpenTelemetry +

+ + + + + + +

+

For Go

+

+

Open-source observability for your LLM application

+

+

+ Get started ยป +
+
+ Slack | + Docs | + Website +

+ +

+ + OpenLLMetry is released under the Apache-2.0 License + + + + PRs welcome! + + + git commit activity + + + Slack community channel + + + Traceloop Twitter + +

+ +OpenLLMetry is a set of extensions built on top of [OpenTelemetry](https://opentelemetry.io/) that gives you complete observability over your LLM application. Because it uses OpenTelemetry under the hood, it can be connected to your existing observability solutions - Datadog, Honeycomb, and others. + +It's built and maintained by Traceloop under the Apache 2.0 license. + +The repo contains standard OpenTelemetry instrumentations for LLM providers and Vector DBs, as well as a Traceloop SDK that makes it easy to get started with OpenLLMetry, while still outputting standard OpenTelemetry data that can be connected to your observability stack. +If you already have OpenTelemetry instrumented, you can just add any of our instrumentations directly. + +## ๐Ÿš€ Getting Started + +The easiest way to get started is to use our SDK. +For a complete guide, go to our [docs](https://traceloop.com/docs/openllmetry/getting-started-go). + +Install the SDK: + +```bash +go get traceloop-sdk +``` + +Then, initialize the SDK in your code: + +```go +package main + +import ( + "context" + + sdk "github.com/traceloop/go-openllmetry/traceloop-sdk" + "github.com/traceloop/go-openllmetry/traceloop-sdk/config" +) + +func main() { + ctx := context.Background() + + traceloop := sdk.NewClient(config.Config{ + BaseURL: "api.traceloop.com", + APIKey: os.Getenv("TRACELOOP_API_KEY"), + }) + defer func() { traceloop.Shutdown(ctx) }() + + traceloop.Initialize(ctx) +} +``` + +That's it. You're now tracing your code with OpenLLMetry! + +Now, you need to decide where to export the traces to. + +## โซ Supported (and tested) destinations + +- [x] [Traceloop](https://www.traceloop.com/docs/openllmetry/integrations/traceloop) +- [x] [Dynatrace](https://www.traceloop.com/docs/openllmetry/integrations/dynatrace) +- [x] [Datadog](https://www.traceloop.com/docs/openllmetry/integrations/datadog) +- [x] [New Relic](https://www.traceloop.com/docs/openllmetry/integrations/newrelic) +- [x] [Honeycomb](https://www.traceloop.com/docs/openllmetry/integrations/honeycomb) +- [x] [Grafana Tempo](https://www.traceloop.com/docs/openllmetry/integrations/grafana) +- [x] [HyperDX](https://www.traceloop.com/docs/openllmetry/integrations/hyperdx) +- [x] [SigNoz](https://www.traceloop.com/docs/openllmetry/integrations/signoz) +- [x] [OpenTelemetry Collector](https://www.traceloop.com/docs/openllmetry/integrations/otel-collector) + +See [our docs](https://traceloop.com/docs/openllmetry/integrations/exporting) for instructions on connecting to each one. + +## ๐Ÿช— What do we instrument? + +OpenLLMetry is in early-alpha exploratory stage, and we're still figuring out what to instrument. +As opposed to other languages, there aren't many official LLM libraries (yet?), so for now you'll have to manually log prompts: + +```go +package main + +import ( + "context" + "fmt" + "os" + + "github.com/sashabaranov/go-openai" + sdk "github.com/traceloop/go-openllmetry/traceloop-sdk" + "github.com/traceloop/go-openllmetry/traceloop-sdk/config" + "github.com/traceloop/go-openllmetry/traceloop-sdk/dto" +) + +func main() { + ctx := context.Background() + + // Initialize Traceloop + traceloop := sdk.NewClient(config.Config{ + BaseURL: "api.traceloop.com", + APIKey: os.Getenv("TRACELOOP_API_KEY"), + }) + defer func() { traceloop.Shutdown(ctx) }() + + traceloop.Initialize(ctx) + + // Call OpenAI like you normally would + resp, err := client.CreateChatCompletion( + context.Background(), + openai.ChatCompletionRequest{ + Model: openai.GPT3Dot5Turbo, + Messages: []openai.ChatCompletionMessage{ + { + Role: openai.ChatMessageRoleUser, + Content: "Tell me a joke about OpenTelemetry!", + }, + }, + }, + ) + + // Log the request and the response + log := dto.PromptLogAttributes{ + Prompt: dto.Prompt{ + Vendor: "openai", + Mode: "chat", + Model: request.Model, + }, + Completion: dto.Completion{ + Model: resp.Model, + }, + Usage: dto.Usage{ + TotalTokens: resp.Usage.TotalTokens, + CompletionTokens: resp.Usage.CompletionTokens, + PromptTokens: resp.Usage.PromptTokens, + }, + } + + for i, message := range request.Messages { + log.Prompt.Messages = append(log.Prompt.Messages, dto.Message{ + Index: i, + Content: message.Content, + Role: message.Role, + }) + } + + for _, choice := range resp.Choices { + log.Completion.Messages = append(log.Completion.Messages, dto.Message{ + Index: choice.Index, + Content: choice.Message.Content, + Role: choice.Message.Role, + }) + } + + traceloop.LogPrompt(ctx, log) +} +``` + +## ๐ŸŒฑ Contributing + +Whether it's big or small, we love contributions โค๏ธ Check out our guide to see how to [get started](https://traceloop.com/docs/openllmetry/contributing/overview). + +Not sure where to get started? You can: + +- [Book a free pairing session with one of our teammates](mailto:nir@traceloop.com?subject=Pairing%20session&body=I'd%20like%20to%20do%20a%20pairing%20session!)! +- Join our Slack, and ask us any questions there. + +## ๐Ÿ’š Community & Support + +- [Slack](https://join.slack.com/t/traceloopcommunity/shared_invite/zt-1plpfpm6r-zOHKI028VkpcWdobX65C~g) (For live discussion with the community and the Traceloop team) +- [GitHub Discussions](https://github.com/traceloop/go-openllmetry/discussions) (For help with building and deeper conversations about features) +- [GitHub Issues](https://github.com/traceloop/go-openllmetry/issues) (For any bugs and errors you encounter using OpenLLMetry) +- [Twitter](https://twitter.com/traceloopdev) (Get news fast) + +## ๐Ÿ™ Special Thanks + +To @patrickdebois, who [suggested the great name](https://x.com/patrickdebois/status/1695518950715473991?s=46&t=zn2SOuJcSVq-Pe2Ysevzkg) we're now using for this repo!