langsmith.mdx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ---
  2. title: '🛠️ LangSmith'
  3. description: 'Integrate with Langsmith to debug and monitor your LLM app'
  4. ---
  5. Embedchain now supports integration with [LangSmith](https://www.langchain.com/langsmith).
  6. To use LangSmith, you need to do the following steps.
  7. 1. Have an account on LangSmith and keep the environment variables in handy
  8. 2. Set the environment variables in your app so that embedchain has context about it.
  9. 3. Just use embedchain and everything will be logged to LangSmith, so that you can better test and monitor your application.
  10. Let's cover each step in detail.
  11. * First make sure that you have created a LangSmith account and have all the necessary variables handy. LangSmith has a [good documentation](https://docs.smith.langchain.com/) on how to get started with their service.
  12. * Once you have setup the account, we will need the following environment variables
  13. ```bash
  14. # Setting environment variable for LangChain Tracing V2 integration.
  15. export LANGCHAIN_TRACING_V2=true
  16. # Setting the API endpoint for LangChain.
  17. export LANGCHAIN_ENDPOINT=https://api.smith.langchain.com
  18. # Replace '<your-api-key>' with your LangChain API key.
  19. export LANGCHAIN_API_KEY=<your-api-key>
  20. # Replace '<your-project>' with your LangChain project name, or it defaults to "default".
  21. export LANGCHAIN_PROJECT=<your-project> # if not specified, defaults to "default"
  22. ```
  23. If you are using Python, you can use the following code to set environment variables
  24. ```python
  25. import os
  26. # Setting environment variable for LangChain Tracing V2 integration.
  27. os.environ['LANGCHAIN_TRACING_V2'] = 'true'
  28. # Setting the API endpoint for LangChain.
  29. os.environ['LANGCHAIN_ENDPOINT'] = 'https://api.smith.langchain.com'
  30. # Replace '<your-api-key>' with your LangChain API key.
  31. os.environ['LANGCHAIN_API_KEY'] = '<your-api-key>'
  32. # Replace '<your-project>' with your LangChain project name.
  33. os.environ['LANGCHAIN_PROJECT'] = '<your-project>'
  34. ```
  35. * Now create an app using Embedchain and everything will be automatically visible in the LangSmith
  36. ```python
  37. from embedchain import App
  38. # Initialize EmbedChain application.
  39. app = App()
  40. # Add data to your app
  41. app.add("https://en.wikipedia.org/wiki/Elon_Musk")
  42. # Query your app
  43. app.query("How many companies did Elon found?")
  44. ```
  45. * Now the entire log for this will be visible in langsmith.
  46. <img src="/images/langsmith.png"/>