MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / execute_inline

Method execute_inline

crates/opencode-session/src/prompt.rs:2784–2833  ·  view source on GitHub ↗
(
        &self,
        provider: Arc<dyn Provider>,
        tool_registry: &opencode_tool::ToolRegistry,
        disabled_tools: &[String],
    )

Source from the content-addressed store, hash-verified

2782 }
2783
2784 pub async fn execute_inline(
2785 &self,
2786 provider: Arc<dyn Provider>,
2787 tool_registry: &opencode_tool::ToolRegistry,
2788 disabled_tools: &[String],
2789 ) -> anyhow::Result<String> {
2790 let model = self.model.as_ref().cloned().unwrap_or(ModelRef {
2791 provider_id: "default".to_string(),
2792 model_id: "default".to_string(),
2793 });
2794 let disabled: HashSet<&str> = disabled_tools.iter().map(|s| s.as_str()).collect();
2795 let tools = tool_registry.list_schemas().await;
2796 let tool_defs: Vec<ToolDefinition> = tools
2797 .into_iter()
2798 .filter(|s| !disabled.contains(s.name.as_str()))
2799 .map(|s| ToolDefinition {
2800 name: s.name,
2801 description: Some(s.description),
2802 parameters: s.parameters,
2803 })
2804 .collect();
2805
2806 let messages = vec![Message::user(&self.prompt)];
2807
2808 let request = ChatRequest {
2809 model: model.model_id,
2810 messages,
2811 max_tokens: Some(self.agent_params.max_tokens.unwrap_or(8192)),
2812 temperature: self.agent_params.temperature,
2813 system: None,
2814 tools: Some(tool_defs),
2815 stream: Some(false),
2816 top_p: self.agent_params.top_p,
2817 variant: None,
2818 provider_options: None,
2819 };
2820
2821 let response = provider.chat(request).await?;
2822
2823 let output = response
2824 .choices
2825 .first()
2826 .and_then(|c| match &c.message.content {
2827 Content::Text(text) => Some(text.clone()),
2828 Content::Parts(parts) => parts.first().and_then(|p| p.text.clone()),
2829 })
2830 .unwrap_or_default();
2831
2832 Ok(output)
2833 }
2834}
2835
2836fn hook_payload_object(

Callers 2

executeMethod · 0.80

Calls 6

list_schemasMethod · 0.80
containsMethod · 0.80
as_strMethod · 0.45
filterMethod · 0.45
chatMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected