gutai123 commited on
Commit
30dff6f
·
verified ·
1 Parent(s): 3b189e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -1,13 +1,19 @@
1
-
2
- from user_utils import *
3
-
4
  import streamlit as st
5
  from dotenv import load_dotenv
 
6
 
7
- def main():
8
- # Load environment variables
9
- load_dotenv()
10
 
 
 
 
 
 
 
 
 
 
11
  st.header("Automatic Ticket Classification Tool")
12
 
13
  # Capture user input
@@ -16,7 +22,7 @@ def main():
16
 
17
  if user_input:
18
  try:
19
- # Create embeddings instance
20
  embeddings = create_embeddings()
21
 
22
  # Fetch the Pinecone index using the API key and environment info
@@ -37,7 +43,7 @@ def main():
37
  # Access the document content directly
38
  content = getattr(doc, "page_content", "No content available.") # Safely access content
39
 
40
- # Apply fine-tuned extraction model
41
  relevant_info = fine_tune_extraction(content, user_input)
42
 
43
  if relevant_info:
 
 
 
 
1
  import streamlit as st
2
  from dotenv import load_dotenv
3
+ from transformers import pipeline
4
 
5
+ # Load environment variables
6
+ load_dotenv()
 
7
 
8
+ # Initialize the question-answering pipeline with a pre-trained model
9
+ qa_pipeline = pipeline("question-answering", model="distilbert-base-uncased-distilled-squad")
10
+
11
+ def fine_tune_extraction(content, query):
12
+ # Use the pipeline to answer the question using the document content
13
+ result = qa_pipeline(question=query, context=content)
14
+ return result['answer']
15
+
16
+ def main():
17
  st.header("Automatic Ticket Classification Tool")
18
 
19
  # Capture user input
 
22
 
23
  if user_input:
24
  try:
25
+ # Assuming create_embeddings and pull_from_pinecone are defined elsewhere
26
  embeddings = create_embeddings()
27
 
28
  # Fetch the Pinecone index using the API key and environment info
 
43
  # Access the document content directly
44
  content = getattr(doc, "page_content", "No content available.") # Safely access content
45
 
46
+ # Apply fine-tuned extraction model to extract relevant information
47
  relevant_info = fine_tune_extraction(content, user_input)
48
 
49
  if relevant_info: