Alimubariz124 commited on
Commit
84176fd
·
verified ·
1 Parent(s): bdba284

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -45,4 +45,28 @@ def query_faiss(query, index, embedder, chunks, top_k=2):
45
  return "\n\n".join(retrieved_chunks)
46
 
47
  # Build prompt and generate answer
48
- def chat_with
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  return "\n\n".join(retrieved_chunks)
46
 
47
  # Build prompt and generate answer
48
+ def chat_with_transcript(query):
49
+ context = query_faiss(query, index, embedder, chunks)
50
+ prompt = f"""You are an AI assistant. Use the following context to answer the question.
51
+ Context:
52
+ {context}
53
+ Question: {query}
54
+ Provide your answer below:
55
+ """
56
+ response = llm(prompt)[0]['generated_text']
57
+ print("Raw model response:", response) # Debug statement
58
+ return response.strip()
59
+
60
+ # Gradio interface
61
+ with gr.Blocks() as demo:
62
+ gr.Markdown("# 📄 Chat with a Transcript")
63
+ query_input = gr.Textbox(label="Ask a question about the transcript")
64
+ answer_output = gr.Textbox(label="Answer")
65
+
66
+ query_input.submit(
67
+ chat_with_transcript,
68
+ inputs=[query_input],
69
+ outputs=[answer_output]
70
+ )
71
+
72
+ demo.launch()