Keira James commited on
Commit
99256f5
·
1 Parent(s): 50d6a8f

switch to simple app

Browse files
Files changed (1) hide show
  1. app.py +6 -25
app.py CHANGED
@@ -1,31 +1,12 @@
1
  import streamlit as st
2
- from transformers import AutoTokenizer, AutoModelForCausalLM
3
 
4
- # Load GPT-2 model and tokenizer
5
- model_name = "gpt2" # You can replace with a different version of GPT-2 if needed
6
- model = AutoModelForCausalLM.from_pretrained(model_name)
7
- tokenizer = AutoTokenizer.from_pretrained(model_name)
8
 
9
- # Function to generate a response from GPT-2
10
- def generate_response(prompt):
11
- # Only generate a response based on the given prompt
12
- inputs = tokenizer(prompt, return_tensors="pt")
13
- output = model.generate(inputs['input_ids'], max_length=150)
14
- response = tokenizer.decode(output[0], skip_special_tokens=True)
15
- return response
16
-
17
- # Streamlit UI
18
- st.title("GPT-2 Data Structures Mentor")
19
-
20
- # Instruction for the chatbot role
21
- st.write("This chatbot is your mentor to help you with learning Data Structures. Ask questions about arrays, linked lists, stacks, queues, trees, graphs, and other related topics!")
22
-
23
- # Text input for the user prompt
24
- user_input = st.text_input("You:", "")
25
 
 
26
  if user_input:
27
- # Adding context to the prompt, but only once for the first input
28
- prompt = f"You are a mentor teaching data structures. Answer the following question: {user_input}"
29
- response = generate_response(prompt)
30
- st.text_area("Mentor's Response:", value=response, height=200, disabled=True)
31
 
 
1
  import streamlit as st
 
2
 
3
+ # Title of the app
4
+ st.title("Simple Streamlit App")
 
 
5
 
6
+ # User input for text
7
+ user_input = st.text_input("Enter some text:")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
 
9
+ # Display the input text
10
  if user_input:
11
+ st.write(f"You entered: {user_input}")
 
 
 
12