Chat is working again
This commit is contained in:
parent
3fc6b1ab4d
commit
c07510c525
@ -358,8 +358,9 @@ class Agent(BaseModel, ABC):
|
|||||||
size=user.file_watcher.collection.count()
|
size=user.file_watcher.collection.count()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
entries += len(rag_metadata.documents)
|
||||||
rag_message.metadata.rag_results.append(rag_metadata)
|
rag_message.metadata.rag_results.append(rag_metadata)
|
||||||
rag_message.content = f"Results from {rag.name} RAG: {len(chroma_results['documents'])} results."
|
rag_message.content = f"Results from {rag.name} RAG: {len(rag_metadata.documents)} results."
|
||||||
yield rag_message
|
yield rag_message
|
||||||
|
|
||||||
rag_message.content = (
|
rag_message.content = (
|
||||||
@ -377,7 +378,7 @@ class Agent(BaseModel, ABC):
|
|||||||
return
|
return
|
||||||
|
|
||||||
async def generate(
|
async def generate(
|
||||||
self, llm: Any, model: str, user_message: ChatMessageUser, user_id: str, temperature=0.7
|
self, llm: Any, model: str, user_message: ChatMessageUser, user: Candidate, temperature=0.7
|
||||||
) -> AsyncGenerator[ChatMessage | ChatMessageBase, None]:
|
) -> AsyncGenerator[ChatMessage | ChatMessageBase, None]:
|
||||||
logger.info(f"{self.agent_type} - {inspect.stack()[0].function}")
|
logger.info(f"{self.agent_type} - {inspect.stack()[0].function}")
|
||||||
|
|
||||||
|
@ -7,11 +7,10 @@ from .base import Agent, agent_registry
|
|||||||
from logger import logger
|
from logger import logger
|
||||||
|
|
||||||
from .registry import agent_registry
|
from .registry import agent_registry
|
||||||
from models import ( ChatQuery, ChatMessage, Tunables, ChatStatusType)
|
from models import ( ChatQuery, ChatMessage, Tunables, ChatStatusType, ChatMessageUser, Candidate)
|
||||||
|
|
||||||
|
|
||||||
system_message = f"""
|
system_message = f"""
|
||||||
Launched on {datetime.now().isoformat()}.
|
|
||||||
|
|
||||||
When answering queries, follow these steps:
|
When answering queries, follow these steps:
|
||||||
|
|
||||||
- First analyze the query to determine if real-time information from the tools might be helpful
|
- First analyze the query to determine if real-time information from the tools might be helpful
|
||||||
@ -57,31 +56,18 @@ class CandidateChat(Agent):
|
|||||||
|
|
||||||
system_prompt: str = system_message
|
system_prompt: str = system_message
|
||||||
|
|
||||||
# async def prepare_message(self, message: Message) -> AsyncGenerator[Message, None]:
|
async def generate(
|
||||||
# logger.info(f"{self.agent_type} - {inspect.stack()[0].function}")
|
self, llm: Any, model: str, user_message: ChatMessageUser, user: Candidate, temperature=0.7
|
||||||
# if not self.context:
|
):
|
||||||
# raise ValueError("Context is not set for this agent.")
|
self.system_prompt = """
|
||||||
|
You are a helpful assistant designed to answer questions about {candidate.full_name}, their resumes, and related topics. You can also generate images based on user requests.
|
||||||
|
|
||||||
# async for message in super().prepare_message(message):
|
{system_message}
|
||||||
# if message.status != "done":
|
"""
|
||||||
# yield message
|
async for message in super().generate(llm, model, user_message, user, temperature):
|
||||||
|
yield message
|
||||||
# if message.preamble:
|
|
||||||
# excluded = {}
|
|
||||||
# preamble_types = [
|
|
||||||
# f"<|{p}|>" for p in message.preamble.keys() if p not in excluded
|
|
||||||
# ]
|
|
||||||
# preamble_types_AND = " and ".join(preamble_types)
|
|
||||||
# preamble_types_OR = " or ".join(preamble_types)
|
|
||||||
# message.preamble[
|
|
||||||
# "rules"
|
|
||||||
# ] = f"""\
|
|
||||||
# - Answer the question based on the information provided in the {preamble_types_AND} sections by incorporate it seamlessly and refer to it using natural language instead of mentioning {preamble_types_OR} or quoting it directly.
|
|
||||||
# - If there is no information in these sections, answer based on your knowledge, or use any available tools.
|
|
||||||
# - Avoid phrases like 'According to the {preamble_types[0]}' or similar references to the {preamble_types_OR}.
|
|
||||||
# """
|
|
||||||
# message.preamble["question"] = "Respond to:"
|
|
||||||
|
|
||||||
|
|
||||||
# Register the base agent
|
# Register the base agent
|
||||||
agent_registry.register(CandidateChat._agent_type, CandidateChat)
|
agent_registry.register(CandidateChat._agent_type, CandidateChat)
|
||||||
|
|
||||||
|
@ -1994,7 +1994,7 @@ async def post_chat_session_message_stream(
|
|||||||
llm=llm_manager.get_llm(),
|
llm=llm_manager.get_llm(),
|
||||||
model=defines.model,
|
model=defines.model,
|
||||||
user_message=user_message,
|
user_message=user_message,
|
||||||
user_id=current_user.id,
|
user=current_user,
|
||||||
):
|
):
|
||||||
# Store reference to the complete AI message
|
# Store reference to the complete AI message
|
||||||
if generated_message.status == ChatStatusType.DONE:
|
if generated_message.status == ChatStatusType.DONE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user