KingZack commited on
Commit
501669a
·
1 Parent(s): 868eb1b

adding app files

Browse files
Files changed (3) hide show
  1. README.md +12 -2
  2. app.py +46 -0
  3. requirements.txt +2 -0
README.md CHANGED
@@ -1,2 +1,12 @@
1
- # pushing-github-to-hf
2
- pushing-github-to-hf
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Pushing Github To Hf
3
+ emoji: 📚
4
+ colorFrom: red
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 5.28.0
8
+ app_file: app.py
9
+ pinned: false
10
+ short_description: pushing-github-to-hf
11
+ ---
12
+
app.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from huggingface_hub import InferenceClient
3
+
4
+
5
+ # MUST SET HF_TOKEN IN STREAMLIT SETTINGS IN HUGGINGFACE REPO SECRETS
6
+ HF_TOKEN = st.secrets["HF_TOKEN"]
7
+
8
+
9
+ # INIT THE INFERENCE CLIENT WITH YOUR HF TOKEN
10
+ client = InferenceClient(
11
+ provider="fireworks-ai",
12
+ api_key=HF_TOKEN,
13
+ )
14
+
15
+ # THIS IS JUST THE streamlit TEXT INPUT WIDGET
16
+ user_input = st.text_input(
17
+ "Place your prompt here",
18
+ "This is a placeholder",
19
+ key="placeholder",
20
+ )
21
+
22
+ # THIS IS THE INFERENCE CLIENT CALL
23
+ completion = client.chat.completions.create(
24
+ model="deepseek-ai/DeepSeek-R1",
25
+ messages=[
26
+ {
27
+ "role": "user",
28
+ "content": user_input
29
+ }
30
+ ],
31
+ max_tokens=512,
32
+ )
33
+
34
+ # THIS IS THE RESPONSE FROM THE INFERENCE CLIENT
35
+ ai_response = completion.choices[0].message.content
36
+
37
+ # THIS IS THE STREAMLIT TEXT OUTPUT WIDGET WITH THE RESPONSE FROM THE INFERENCE CLIENT
38
+ st.text(ai_response)
39
+
40
+
41
+ ### WRONG WAY TO TRY AND LOAD MODELS:::
42
+ # Load model directly
43
+ # from transformers import AutoTokenizer, AutoModelForCausalLM
44
+
45
+ # tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-Prover-V2-671B", trust_remote_code=True)
46
+ # model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-Prover-V2-671B", trust_remote_code=True)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ streamlit
2
+ huggingface_hub