MudassirFayaz commited on
Commit
f4cb21e
1 Parent(s): 6f56570

added folders

Browse files
Files changed (1) hide show
  1. app.py +22 -17
app.py CHANGED
@@ -1,24 +1,29 @@
1
  import streamlit as st
2
- import requests
 
3
 
4
- # API details
5
- API_URL = "https://api-inference.huggingface.co/models/MudassirFayaz/career_councling_using_bart"
6
- headers = {"Authorization": "Bearer "}
 
7
 
8
-
9
- def query(payload):
10
- response = requests.post(API_URL, headers=headers, json=payload)
11
- return response.json()
 
 
 
12
 
13
  # Streamlit app
14
- st.title("Career Counseling using BART")
15
- st.write("Enter a prompt and get a response from the BART model for career counseling.")
16
 
17
- # User input
18
- user_input = st.text_area("Enter your prompt here:", "The answer to the universe is")
19
 
20
- if st.button("Get Response"):
21
- with st.spinner("Querying the API..."):
22
- output = query({"inputs": user_input})
23
- st.success("Response received!")
24
- st.write("**Output:**", output)
 
 
1
  import streamlit as st
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM
3
+ import torch
4
 
5
+ # Load the tokenizer and model
6
+ tokenizer = AutoTokenizer.from_pretrained('tokenizer-llama_career_0.5.0')
7
+ model = AutoModelForCausalLM.from_pretrained('llama-2-7b-career-0.5.0',
8
+ adapter_name_or_path='path/to/model/folder/adapter_model.bin')
9
 
10
+ # Function to generate response
11
+ def generate_response(input_text):
12
+ inputs = tokenizer(input_text, return_tensors='pt')
13
+ with torch.no_grad():
14
+ outputs = model.generate(**inputs, max_length=50, do_sample=True)
15
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
16
+ return response
17
 
18
  # Streamlit app
19
+ st.title("Hugging Face Model Chatbot")
20
+ st.write("Interact with your custom model")
21
 
22
+ input_text = st.text_input("You:", "")
 
23
 
24
+ if st.button("Generate Response"):
25
+ if input_text:
26
+ response = generate_response(input_text)
27
+ st.write(f"Model: {response}")
28
+ else:
29
+ st.write("Please enter some text.")