Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import os
|
3 |
+
from together import Together
|
4 |
+
|
5 |
+
# Initialize the Llama-3 client
|
6 |
+
client = Together(api_key=os.environ.get("TOGETHER_API_KEY"))
|
7 |
+
|
8 |
+
def get_response(question):
|
9 |
+
response = client.chat.completions.create(
|
10 |
+
model="meta-llama/Llama-3-8b-chat-hf",
|
11 |
+
messages=[{"role": "user", "content": question}],
|
12 |
+
)
|
13 |
+
return response.choices[0].message.content
|
14 |
+
|
15 |
+
# Setting up Streamlit interface
|
16 |
+
st.title('RAG based PDF Chatbot')
|
17 |
+
user_input = st.text_input("Ask me anything!")
|
18 |
+
if user_input:
|
19 |
+
answer = get_response(user_input)
|
20 |
+
st.text_area("Answer:", value=answer, height=300)
|