Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add reader file format ipynb #1284

Merged
merged 9 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add files via upload
Signed-off-by: Birdup <34012548+birdup000@users.noreply.github.com>
  • Loading branch information
birdup000 authored Nov 25, 2024
commit e7c1f9a97424431dab0361457b01b3c8d0b8fc96
28 changes: 21 additions & 7 deletions agixt/Chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,20 +523,29 @@ def move_step(self, chain_name, current_step_number, new_step_number):
def get_step_response(self, chain_name, chain_run_id=None, step_number="all"):
if chain_run_id is None:
chain_run_id = self.get_last_chain_run_id(chain_name=chain_name)

chain_data = self.get_chain(chain_name=chain_name)

if isinstance(chain_data, list) and not chain_data: # Check if chain not found

# Handle empty chain data
if not chain_data:
return None


# Get chain ID safely
chain_id = chain_data.get("id") if isinstance(chain_data, dict) else None

if not chain_id:
return None

session = get_session()

if step_number == "all":
chain_steps = (
session.query(ChainStep)
.filter(ChainStep.chain_id == chain_data["id"])
.filter(ChainStep.chain_id == chain_id)
.order_by(ChainStep.step_number)
.all()
)

responses = {}
for step in chain_steps:
chain_step_responses = (
Expand All @@ -548,21 +557,24 @@ def get_step_response(self, chain_name, chain_run_id=None, step_number="all"):
.order_by(ChainStepResponse.timestamp)
.all()
)

step_responses = [response.content for response in chain_step_responses]
responses[str(step.step_number)] = step_responses

session.close()
return responses

else:
step_number = int(step_number)
chain_step = (
session.query(ChainStep)
.filter(
ChainStep.chain_id == chain_data["id"],
ChainStep.chain_id == chain_id,
ChainStep.step_number == step_number,
)
.first()
)

if chain_step:
chain_step_responses = (
session.query(ChainStepResponse)
Expand All @@ -573,9 +585,11 @@ def get_step_response(self, chain_name, chain_run_id=None, step_number="all"):
.order_by(ChainStepResponse.timestamp)
.all()
)

step_responses = [response.content for response in chain_step_responses]
session.close()
return step_responses

else:
session.close()
return None
Expand Down