Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,7 +7,11 @@ import faiss
|
|
| 7 |
import nltk
|
| 8 |
from groq import Groq
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
# Initialize Groq client
|
| 13 |
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
|
@@ -96,18 +100,4 @@ def main():
|
|
| 96 |
st.header("Ask Questions")
|
| 97 |
query = st.text_input("Enter your question here")
|
| 98 |
if st.button("Query Document"):
|
| 99 |
-
results = query_faiss(st.session_state['faiss_index'],
|
| 100 |
-
st.write("### Results from Document:")
|
| 101 |
-
for i, result in enumerate(results):
|
| 102 |
-
st.write(f"**Result {i+1}:** {result}")
|
| 103 |
-
|
| 104 |
-
# Use Groq API for additional insights
|
| 105 |
-
chat_completion = client.chat.completions.create(
|
| 106 |
-
messages=[{"role": "user", "content": query}],
|
| 107 |
-
model="llama-3.3-70b-versatile",
|
| 108 |
-
)
|
| 109 |
-
st.write("### Insights from Groq-powered Model:")
|
| 110 |
-
st.write(chat_completion.choices[0].message.content)
|
| 111 |
-
|
| 112 |
-
if __name__ == "__main__":
|
| 113 |
-
main()
|
|
|
|
| 7 |
import nltk
|
| 8 |
from groq import Groq
|
| 9 |
|
| 10 |
+
# Ensure the punkt tokenizer is downloaded
|
| 11 |
+
try:
|
| 12 |
+
nltk.data.find('tokenizers/punkt')
|
| 13 |
+
except LookupError:
|
| 14 |
+
nltk.download('punkt')
|
| 15 |
|
| 16 |
# Initialize Groq client
|
| 17 |
client = Groq(api_key=os.getenv("GROQ_API_KEY"))
|
|
|
|
| 100 |
st.header("Ask Questions")
|
| 101 |
query = st.text_input("Enter your question here")
|
| 102 |
if st.button("Query Document"):
|
| 103 |
+
results = query_faiss(st.session_state['faiss_index'],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|