fix(api): remove unnecessary Result from tool call start events
Resolves clippy::unnecessary_wraps on ToolCallState::start_event in openai_compat.rs. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
parent
23ba21bdd5
commit
722eee3ea5
1 changed files with 6 additions and 6 deletions
|
|
@ -385,7 +385,7 @@ impl StreamState {
|
||||||
state.apply(tool_call);
|
state.apply(tool_call);
|
||||||
let block_index = state.block_index();
|
let block_index = state.block_index();
|
||||||
if !state.started {
|
if !state.started {
|
||||||
if let Some(start_event) = state.start_event()? {
|
if let Some(start_event) = state.start_event() {
|
||||||
state.started = true;
|
state.started = true;
|
||||||
events.push(StreamEvent::ContentBlockStart(start_event));
|
events.push(StreamEvent::ContentBlockStart(start_event));
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -437,7 +437,7 @@ impl StreamState {
|
||||||
|
|
||||||
for state in self.tool_calls.values_mut() {
|
for state in self.tool_calls.values_mut() {
|
||||||
if !state.started {
|
if !state.started {
|
||||||
if let Some(start_event) = state.start_event()? {
|
if let Some(start_event) = state.start_event() {
|
||||||
state.started = true;
|
state.started = true;
|
||||||
events.push(StreamEvent::ContentBlockStart(start_event));
|
events.push(StreamEvent::ContentBlockStart(start_event));
|
||||||
if let Some(delta_event) = state.delta_event() {
|
if let Some(delta_event) = state.delta_event() {
|
||||||
|
|
@ -505,22 +505,22 @@ impl ToolCallState {
|
||||||
self.openai_index + 1
|
self.openai_index + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start_event(&self) -> Result<Option<ContentBlockStartEvent>, ApiError> {
|
fn start_event(&self) -> Option<ContentBlockStartEvent> {
|
||||||
let Some(name) = self.name.clone() else {
|
let Some(name) = self.name.clone() else {
|
||||||
return Ok(None);
|
return None;
|
||||||
};
|
};
|
||||||
let id = self
|
let id = self
|
||||||
.id
|
.id
|
||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| format!("tool_call_{}", self.openai_index));
|
.unwrap_or_else(|| format!("tool_call_{}", self.openai_index));
|
||||||
Ok(Some(ContentBlockStartEvent {
|
Some(ContentBlockStartEvent {
|
||||||
index: self.block_index(),
|
index: self.block_index(),
|
||||||
content_block: OutputContentBlock::ToolUse {
|
content_block: OutputContentBlock::ToolUse {
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
input: json!({}),
|
input: json!({}),
|
||||||
},
|
},
|
||||||
}))
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn delta_event(&mut self) -> Option<ContentBlockDeltaEvent> {
|
fn delta_event(&mut self) -> Option<ContentBlockDeltaEvent> {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue