File size: 2,914 Bytes
1855ec1
 
 
 
 
fb831d6
 
1855ec1
 
fb831d6
1855ec1
fb831d6
2dd27c9
 
cd46d41
 
 
1855ec1
 
 
 
 
 
 
 
cd46d41
ce5d5d0
845ed2b
1855ec1
 
 
 
 
 
 
 
96a2b00
 
 
 
 
 
 
 
 
 
 
1855ec1
 
3a5a4c6
96a2b00
 
 
 
 
 
 
 
 
324b092
 
1855ec1
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
---
title: Test
emoji: πŸš€
colorFrom: green
colorTo: green
sdk: streamlit
sdk_version: 1.46.0
pinned: false
app_file: app/app.py
license: other
---

# Hands-On AI: Building and Deploying LLM-Powered Apps
This is the repository for the LinkedIn Learning course `Hands-On AI: Building and Deploying LLM-Powered Apps`. The full course is available from [LinkedIn Learning][lil-course-url].

_See the readme file in the main branch for updated instructions and information._

## Lab 7: Deploying the application to Huggingface and trace the application outputs on Langsmith

Now we have the application up and running, lets deploy it to Huggingface Spaces and trace the applicatio outputs on Langsmith. This way we can proudly show our work and keep record of what our users are doing with our application!

Before that happens, please register your account on Huggingface and Langsmith.

> NOTE: [Huggingface Spaces](https://huggingface.co/pricing) provides free tier access starting at $0.
> NOTE: [Langsmith](https://www.langchain.com/pricing-langsmith) is a paid application with a Developer tier license that gives access to 1 user and 5k traces per month.

## Exercises

After registering accounts on Huggingface and Langsmith, please grab the API keys and lets get to work.

Oh, and currently we have OpenAI API key baked into our application. Lets make sure that users of our application need to input their own key to use the application!

And then we will setup CI/CD for automated deployment.

Complete the exercises in `app/app.py` and `.env` (see `.env.sample`). Make sure you follow the instruction here: [https://huggingface.co/docs/hub/en/spaces-github-actions](https://huggingface.co/docs/hub/en/spaces-github-actions) and here [Hugging Face Hub: Important Git Authentication Changes](https://huggingface.co/blog/password-git-deprecation).

After deployment, please remember to into Huggingface Space settings to setup the following environment variables and secrets:
```
# Variables
LANGSMITH_TRACING="true"
LANGSMITH_ENDPOINT="https://api.smith.langchain.com"
LANGSMITH_PROJECT="linkedin_learning"
ALLOW_RESET="true"

# Secrets
LANGSMITH_API_KEY=""
```

> NOTE: To reduce the scope, we will manually deploy to Huggingface Only. We prepared `.github/workflows/deploy-to-hf.yml` workflow as an extracurricular exercise for the learner.

> NOTE: if you are deploying from this current branch `03_06`, plase do
```
git push --force space 03_06:main
```
otherwise if you fork this repository and deploy from your own main branch
```
git push --force space main
```

## References

- [Huggingface Spaces](https://huggingface.co/pricing)
- [Langsmith](https://www.langchain.com/pricing-langsmith)
- [Huggingface Spaces Github Actions](https://huggingface.co/docs/hub/en/spaces-github-actions)
- [Hugging Face Hub: Important Git Authentication Changes](https://huggingface.co/blog/password-git-deprecation)