Skip to content

Commit

Permalink
feat: Improve context handling and validation in agent creation and r…
Browse files Browse the repository at this point in the history
…eliability processing
  • Loading branch information
onuratakan committed Feb 13, 2025
1 parent 84ef487 commit 1d6e30c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/upsonic/reliability_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ def process_result(
validator_agent = AgentConfiguration("Information Validator Agent", model=llm_model, sub_task=False)
copy_task = deepcopy(task)
copy_task._response = result
validator_task = Task("Evaluate the old question and its answer for correctness, consistency, and completeness", context=[copy_task], response_format=ValidationResult, tools=task.tools)
validator_task = Task("Evaluate the old question and its answer for correctness, consistency, and completeness. Also thing for the requested output. Do not allow unverified information and guesses.", context=[copy_task, copy_task.response_format], response_format=ValidationResult, tools=task.tools)
validator_agent.do(validator_task)

if validator_task.response.result == True:
return result
else:
editor_agent = AgentConfiguration("Information Editor Agent", model=llm_model, sub_task=False)
editor_task = Task("Edit the answer to the question to correct the inaccuracies by the feedback provided", context=[copy_task, validator_task], response_format=task.response_format, tools=task.tools)
editor_task = Task("Edit the answer to the question to correct the inaccuracies by the feedback provided", context=[copy_task, copy_task.response_format, validator_task], response_format=task.response_format, tools=task.tools)
editor_agent.do(editor_task)

return editor_task.response
Expand Down
9 changes: 9 additions & 0 deletions src/upsonic/server/level_utilized/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,15 @@ def agent_creator(
from ...client.level_two.agent import Characterization
from ...client.level_two.agent import OtherTask
from ...client.tasks.tasks import Task
from ...client.tasks.task_response import ObjectResponse
from ...client.knowledge_base.knowledge_base import KnowledgeBase
type_string = type(each).__name__
the_class_string = None
try:
the_class_string = each.__bases__[0].__name__
except:
pass


if type_string == Characterization.__name__:
context_string += f"\n\nThis is your character ```character {each.model_dump()}```"
Expand All @@ -369,6 +376,8 @@ def agent_creator(
response = each.response

context_string += f"\n\nContexts from question answering: ```question_answering question: {description} answer: {response}``` "
elif the_class_string == ObjectResponse.__name__:
context_string += f"\n\nContexts from object response: ```Requested Output {each.model_fields}```"
else:
context_string += f"\n\nContexts ```context {each}```"

Expand Down

0 comments on commit 1d6e30c

Please sign in to comment.