abaliyan commited on
Commit
174f6e7
1 Parent(s): 6640043

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from langchain_community.llms import CTransformers
3
+
4
+ st.title("Generating Response with HuggingFace Models")
5
+ st.markdown("## Model: `marella/gpt-2-ggml`")
6
+
7
+ def get_response(question: str) -> str:
8
+ """
9
+ This function takes a user input question and returns the response from the LLM model.
10
+
11
+ Args:
12
+ question (str): The user input question.
13
+
14
+ Returns:
15
+ str: The response from the LLM model.
16
+
17
+ """
18
+ llm = CTransformers(model="marella/gpt-2-ggml")
19
+ response = llm.invoke(question)
20
+ st.write(response)
21
+ return response
22
+
23
+ user_input = st.text_area("Enter your query here...")
24
+
25
+ if st.button("Get Response") and user_input:
26
+ with st.spinner("Generating Response..."):
27
+ answer = get_response(user_input)
28
+ if answer is not None:
29
+ st.success('Great! Response generated successfully')
30
+ st.write(answer)