flawlessfr commited on
Commit
e35e785
·
verified ·
1 Parent(s): bab0b25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -3
app.py CHANGED
@@ -15,13 +15,13 @@ retriever = vectorstore.as_retriever(search_kwargs={"k": 5})
15
  hf_token = os.environ.get("HF_TOKEN")
16
  llm = HuggingFaceEndpoint(
17
  repo_id="HuggingFaceH4/zephyr-7b-beta",
18
- task="text-generation",
19
  max_new_tokens=512,
20
  temperature=0.1,
21
  huggingfacehub_api_token=hf_token
22
  )
23
 
24
- # 3. Create the RAG Chain using modern LCEL (No langchain.chains needed!)
25
  system_prompt = (
26
  "You are an expert C++ programming assistant. You answer questions strictly based "
27
  "on the provided context from learncpp.com. If the answer is not in the context, "
@@ -68,7 +68,8 @@ demo = gr.ChatInterface(
68
  fn=chat_function,
69
  title="LearnCpp.com AI Assistant",
70
  description="Ask me any C++ question! I retrieve my answers directly from the complete LearnCpp tutorials.",
71
- examples=["What is a pointer?", "Explain dynamic memory allocation.", "Give me an example of the previous concept."]
 
72
  )
73
 
74
  if __name__ == "__main__":
 
15
  hf_token = os.environ.get("HF_TOKEN")
16
  llm = HuggingFaceEndpoint(
17
  repo_id="HuggingFaceH4/zephyr-7b-beta",
18
+ # REMOVED the "task" parameter to prevent backend routing clashes
19
  max_new_tokens=512,
20
  temperature=0.1,
21
  huggingfacehub_api_token=hf_token
22
  )
23
 
24
+ # 3. Create the RAG Chain using modern LCEL
25
  system_prompt = (
26
  "You are an expert C++ programming assistant. You answer questions strictly based "
27
  "on the provided context from learncpp.com. If the answer is not in the context, "
 
68
  fn=chat_function,
69
  title="LearnCpp.com AI Assistant",
70
  description="Ask me any C++ question! I retrieve my answers directly from the complete LearnCpp tutorials.",
71
+ examples=["What is a pointer?", "Explain dynamic memory allocation.", "Give me an example of the previous concept."],
72
+ type="tuples" # ADDED THIS: Forces Gradio to use the format our memory loop expects!
73
  )
74
 
75
  if __name__ == "__main__":