InkeyDevelopment commited on
Commit
6d3f718
·
verified ·
1 Parent(s): 70997bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -20
app.py CHANGED
@@ -17,26 +17,27 @@ app = Flask(__name__)
17
  # Load Model and FAISS Index
18
 
19
 
20
- # AzureOpenAiEndpoint= os.getenv("AZURE_OPENAI_ENDPOINT")
21
- # AzureOpenAiKey= os.getenv("AZURE_OPENAI_KEY")
22
- # OpenaiApiVersion= os.getenv("OPENAI_API_VERSION")
23
- # DeploymentName= os.getenv("DEPLOYMENT_NAME")
 
24
  model = SentenceTransformer('./sentence-transformers_all-MiniLM-L6-v2')
25
  index = faiss.read_index("faiss_index.bin")
26
- groq_api_key = os.getenv('GROQ_API_KEY')
27
- model_name = "llama-3.3-70b-versatile"
28
-
29
- # llm = AzureChatOpenAI(
30
- # openai_api_version= OpenaiApiVersion, # Change based on your API version
31
- # deployment_name = DeploymentName, # The model deployment name in Azure
32
- # openai_api_key= AzureOpenAiKey, # Use the environment variable
33
- # azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], # Use the environment variable
34
- # )
35
- llm = ChatGroq(
36
- temperature=0,
37
- groq_api_key=groq_api_key,
38
- model_name=model_name
39
- )
40
 
41
  with open("metadata.json") as f:
42
  metadata = json.load(f)
@@ -162,6 +163,8 @@ def query_pdf():
162
  """
163
  ### YOU ARE AN EXELSYS EASYHR GUIDE ASSISTANT:
164
  ### INSTRUCTIONS:
 
 
165
  - Your job is to provide step-by-step guidance for the following user query.
166
  - Check user query and provide relevant information from the Exelsys easyHR PDF.
167
  - Only provide image path if they are relevant to or you response and user query.
@@ -171,7 +174,7 @@ def query_pdf():
171
  - If no relevant information is found, simply respond with: "Not found."
172
  - If the user greets you (e.g., "Hello", "Hi", "Good morning"), respond politely but keep it brief.
173
  - If the query is unrelated to Exelsys easyHR, respond with: "I'm here to assist with Exelsys easyHR queries only."
174
- - Put images path after response text.
175
 
176
  ### USER QUERY:
177
  {query}
@@ -203,7 +206,7 @@ def query_pdf():
203
  "text": cleaned_text,
204
  "images": extracted_images # Store multiple images in a list
205
  }
206
-
207
 
208
  return jsonify(response)
209
 
 
17
  # Load Model and FAISS Index
18
 
19
 
20
+ AzureOpenAiEndpoint= os.getenv("AZURE_OPENAI_ENDPOINT")
21
+ AzureOpenAiKey= os.getenv("AZURE_OPENAI_KEY")
22
+ OpenaiApiVersion= os.getenv("OPENAI_API_VERSION")
23
+ DeploymentName= os.getenv("DEPLOYMENT_NAME")
24
+
25
  model = SentenceTransformer('./sentence-transformers_all-MiniLM-L6-v2')
26
  index = faiss.read_index("faiss_index.bin")
27
+ # groq_api_key = os.getenv('GROQ_API_KEY')
28
+ # model_name = "llama-3.3-70b-versatile"
29
+
30
+ llm = AzureChatOpenAI(
31
+ openai_api_version= OpenaiApiVersion, # Change based on your API version
32
+ deployment_name = DeploymentName, # The model deployment name in Azure
33
+ openai_api_key= AzureOpenAiKey, # Use the environment variable
34
+ azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"], # Use the environment variable
35
+ )
36
+ # llm = ChatGroq(
37
+ # temperature=0,
38
+ # groq_api_key=groq_api_key,
39
+ # model_name=model_name
40
+ # )
41
 
42
  with open("metadata.json") as f:
43
  metadata = json.load(f)
 
163
  """
164
  ### YOU ARE AN EXELSYS EASYHR GUIDE ASSISTANT:
165
  ### INSTRUCTIONS:
166
+ ### YOU ARE AN EXELSYS EASYHR GUIDE ASSISTANT:
167
+ ### INSTRUCTIONS:
168
  - Your job is to provide step-by-step guidance for the following user query.
169
  - Check user query and provide relevant information from the Exelsys easyHR PDF.
170
  - Only provide image path if they are relevant to or you response and user query.
 
174
  - If no relevant information is found, simply respond with: "Not found."
175
  - If the user greets you (e.g., "Hello", "Hi", "Good morning"), respond politely but keep it brief.
176
  - If the query is unrelated to Exelsys easyHR, respond with: "I'm here to assist with Exelsys easyHR queries only."
177
+ - Put images path after response text.
178
 
179
  ### USER QUERY:
180
  {query}
 
206
  "text": cleaned_text,
207
  "images": extracted_images # Store multiple images in a list
208
  }
209
+ print(response)
210
 
211
  return jsonify(response)
212