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

Fix/assistant none type #2143

Merged
merged 4 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions api/core/features/assistant_cot_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ def _convert_strachpad_list_to_str(self, agent_scratchpad: List[AgentScratchpadU

result = ''
for scratchpad in agent_scratchpad:
result += scratchpad.thought + next_iteration.replace("{{observation}}", scratchpad.observation) + "\n"
result += scratchpad.thought + next_iteration.replace("{{observation}}", scratchpad.observation or '') + "\n"

return result

Expand Down Expand Up @@ -543,7 +543,7 @@ def _originze_cot_prompt_messages(self, mode: Literal["completion", "chat"],
# add assistant message
if len(agent_scratchpad) > 0:
prompt_messages.append(AssistantPromptMessage(
content=agent_scratchpad[-1].thought + "\n" + agent_scratchpad[-1].observation
content=(agent_scratchpad[-1].thought or '') + "\n" + (agent_scratchpad[-1].observation or '')
))

# add user message
Expand Down
2 changes: 0 additions & 2 deletions api/core/features/assistant_fc_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ def increase_usage(final_llm_usage_dict: Dict[str, LLMUsage], usage: LLMUsage):
for tool_call_id, tool_call_name, tool_call_args in tool_calls:
tool_instance = tool_instances.get(tool_call_name)
if not tool_instance:
logger.error(f"failed to find tool instance: {tool_call_name}")
tool_response = {
"tool_call_id": tool_call_id,
"tool_call_name": tool_call_name,
Expand Down Expand Up @@ -220,7 +219,6 @@ def increase_usage(final_llm_usage_dict: Dict[str, LLMUsage], usage: LLMUsage):

if error_response:
observation = error_response
logger.error(error_response)
tool_response = {
"tool_call_id": tool_call_id,
"tool_call_name": tool_call_name,
Expand Down
2 changes: 1 addition & 1 deletion api/core/tools/provider/builtin/yahoo/tools/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def _invoke(self, user_id: str, tool_paramters: Dict[str, Any]) \

stock_data = download(symbol, start=time_range[0], end=time_range[1])
max_segments = min(15, len(stock_data))
rows_per_segment = len(stock_data) // max_segments
rows_per_segment = len(stock_data) // (max_segments or 1)
summary_data = []
for i in range(max_segments):
start_idx = i * rows_per_segment
Expand Down
Loading