Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,20 +8,15 @@ from langchain_groq import ChatGroq
|
|
8 |
import gradio as gr
|
9 |
|
10 |
# Initialize Groq
|
11 |
-
# llm = ChatGroq(
|
12 |
-
# api_key=os.environ.get("GROQ_API_KEY"),
|
13 |
-
# model_name="deepseek-r1-distill-llama-70b"
|
14 |
-
# )
|
15 |
-
|
16 |
llm = ChatGroq(
|
17 |
-
api_key=
|
18 |
-
model_name="
|
19 |
)
|
20 |
|
21 |
def create_rag_system():
|
22 |
try:
|
23 |
# 1. Load Documents
|
24 |
-
pdf_loader = PyPDFLoader("
|
25 |
pdf_docs = pdf_loader.load()
|
26 |
|
27 |
# 2. Split Documents
|
@@ -63,7 +58,9 @@ def respond(message, history):
|
|
63 |
)
|
64 |
|
65 |
# Get response
|
66 |
-
|
|
|
|
|
67 |
return response
|
68 |
except Exception as e:
|
69 |
return f"An error occurred: {str(e)}"
|
|
|
8 |
import gradio as gr
|
9 |
|
10 |
# Initialize Groq
|
|
|
|
|
|
|
|
|
|
|
11 |
llm = ChatGroq(
|
12 |
+
api_key="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",
|
13 |
+
model_name="llama-3.1-8b-instant"
|
14 |
)
|
15 |
|
16 |
def create_rag_system():
|
17 |
try:
|
18 |
# 1. Load Documents
|
19 |
+
pdf_loader = PyPDFLoader("smarthome_hub_documentation_Final.pdf")
|
20 |
pdf_docs = pdf_loader.load()
|
21 |
|
22 |
# 2. Split Documents
|
|
|
58 |
)
|
59 |
|
60 |
# Get response
|
61 |
+
|
62 |
+
rag_prompt = f"""Jawablah pertanyaan berikut dalam Bahasa Indonesia: {message}"""
|
63 |
+
response = qa_chain.run(rag_prompt)
|
64 |
return response
|
65 |
except Exception as e:
|
66 |
return f"An error occurred: {str(e)}"
|