Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from langchain.agents import initialize_agent, AgentType,Tool
|
|
| 7 |
from langchain.schema import HumanMessage
|
| 8 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 9 |
from langchain_openai import ChatOpenAI
|
|
|
|
| 10 |
import gradio as gr
|
| 11 |
import os
|
| 12 |
import pytesseract
|
|
@@ -347,24 +348,25 @@ llm = ChatOpenAI(
|
|
| 347 |
temperature=1,
|
| 348 |
max_tokens=None,
|
| 349 |
timeout=None,
|
| 350 |
-
max_retries=5
|
| 351 |
-
prompt_template="""
|
| 352 |
-
You are JobAI.You process user input and generate human-like responses to assist with job searching and application processes. Tasks include:
|
| 353 |
-
(provide links where ever required)
|
| 354 |
-
|
| 355 |
-
- Searching for job openings based on user criteria
|
| 356 |
-
- Providing job descriptions and requirements
|
| 357 |
-
- Analyzing user resumes and offering suggestions for improvement
|
| 358 |
-
- Generating cover letters tailored to specific job openings
|
| 359 |
-
- Offering interview preparation assistance
|
| 360 |
-
|
| 361 |
-
Respond to user queries and engage in conversation to guide them through the job application process. Utilize context and understanding to provide accurate and helpful responses
|
| 362 |
-
{{history}}
|
| 363 |
-
User Query: {{query}}
|
| 364 |
-
|
| 365 |
-
""",
|
| 366 |
)
|
| 367 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 368 |
agent_tools = [ipc_tool, crpc_tool, doj_tool, faq_tool]
|
| 369 |
|
| 370 |
agent = initialize_agent(
|
|
@@ -400,7 +402,7 @@ def chatbot_response(history,query):
|
|
| 400 |
message = HumanMessage(content=[{"type": "text", "text": query}])
|
| 401 |
|
| 402 |
# Invoke the model with the multimodal message
|
| 403 |
-
result = agent.invoke(
|
| 404 |
response = result['output']
|
| 405 |
intermediate_steps = result.get('intermediate_steps', [])
|
| 406 |
|
|
|
|
| 7 |
from langchain.schema import HumanMessage
|
| 8 |
from langchain_google_genai import ChatGoogleGenerativeAI
|
| 9 |
from langchain_openai import ChatOpenAI
|
| 10 |
+
from langchain.prompts import PromptTemplate
|
| 11 |
import gradio as gr
|
| 12 |
import os
|
| 13 |
import pytesseract
|
|
|
|
| 348 |
temperature=1,
|
| 349 |
max_tokens=None,
|
| 350 |
timeout=None,
|
| 351 |
+
max_retries=5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
)
|
| 353 |
|
| 354 |
+
prompt_template = PromptTemplate(
|
| 355 |
+
input_variables=["history", "query"],
|
| 356 |
+
template="""
|
| 357 |
+
You are JobAI. You process user input and generate human-like responses to assist with job searching and application processes. Tasks include:
|
| 358 |
+
(provide links where ever required)
|
| 359 |
+
- Searching for job openings based on user criteria
|
| 360 |
+
- Providing job descriptions and requirements
|
| 361 |
+
- Analyzing user resumes and offering suggestions for improvement
|
| 362 |
+
- Generating cover letters tailored to specific job openings
|
| 363 |
+
- Offering interview preparation assistance
|
| 364 |
+
Respond to user queries and engage in conversation to guide them through the job application process. Utilize context and understanding to provide accurate and helpful responses
|
| 365 |
+
{{history}}
|
| 366 |
+
|
| 367 |
+
User Query: {{query}}
|
| 368 |
+
"""
|
| 369 |
+
)
|
| 370 |
agent_tools = [ipc_tool, crpc_tool, doj_tool, faq_tool]
|
| 371 |
|
| 372 |
agent = initialize_agent(
|
|
|
|
| 402 |
message = HumanMessage(content=[{"type": "text", "text": query}])
|
| 403 |
|
| 404 |
# Invoke the model with the multimodal message
|
| 405 |
+
result = agent.invoke({'history':history,'input':message.context},handle_parsing_errors=True)
|
| 406 |
response = result['output']
|
| 407 |
intermediate_steps = result.get('intermediate_steps', [])
|
| 408 |
|