mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-06 08:18:39 +00:00
Fix merge conflicts in openrouter.ts and Task.ts
This commit is contained in:
parent
05835e0c65
commit
c1d4d703d6
2 changed files with 21 additions and 56 deletions
|
|
@ -25,12 +25,8 @@ import { getModelEndpoints } from "./fetchers/modelEndpointCache"
|
|||
|
||||
import { DEFAULT_HEADERS } from "./constants"
|
||||
import { BaseProvider } from "./base-provider"
|
||||
<<<<<<< HEAD
|
||||
import type { ApiHandlerCreateMessageMetadata, SingleCompletionHandler } from "../index"
|
||||
=======
|
||||
import type { SingleCompletionHandler } from "../index"
|
||||
import { ReasoningDetail } from "../transform/openrouter-reasoning"
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
import { handleOpenAIError } from "./utils/openai-error-handler"
|
||||
|
||||
// Image generation types
|
||||
|
|
@ -221,11 +217,30 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
|
|||
const finishReason = chunk.choices[0]?.finish_reason
|
||||
|
||||
if (delta) {
|
||||
<<<<<<< HEAD
|
||||
if ("reasoning" in delta && delta.reasoning && typeof delta.reasoning === "string") {
|
||||
yield { type: "reasoning", text: delta.reasoning }
|
||||
}
|
||||
|
||||
// OpenRouter passes reasoning details that we can pass back unmodified in api requests to preserve reasoning traces for model
|
||||
// See: https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks
|
||||
if (
|
||||
"reasoning_details" in delta &&
|
||||
(delta as any).reasoning_details &&
|
||||
!shouldSkipReasoningForModel(this.options.openRouterModelId)
|
||||
) {
|
||||
yield {
|
||||
type: "reasoning_details",
|
||||
reasoning_details: (delta as any).reasoning_details,
|
||||
}
|
||||
}
|
||||
|
||||
if (delta && "reasoning_details" in delta && (delta as any).reasoning_details) {
|
||||
yield {
|
||||
type: "reasoning_details",
|
||||
reasoning_details: (delta as any).reasoning_details as ReasoningDetail,
|
||||
}
|
||||
}
|
||||
|
||||
// Check for tool calls in delta
|
||||
if ("tool_calls" in delta && Array.isArray(delta.tool_calls)) {
|
||||
for (const toolCall of delta.tool_calls) {
|
||||
|
|
@ -248,34 +263,8 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH
|
|||
}
|
||||
}
|
||||
|
||||
// OpenRouter passes reasoning details that we can pass back unmodified in api requests to preserve reasoning traces for model
|
||||
// See: https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks
|
||||
if (
|
||||
"reasoning_details" in delta &&
|
||||
(delta as any).reasoning_details &&
|
||||
!shouldSkipReasoningForModel(this.options.openRouterModelId)
|
||||
) {
|
||||
yield {
|
||||
type: "reasoning_details",
|
||||
reasoning_details: (delta as any).reasoning_details,
|
||||
}
|
||||
}
|
||||
|
||||
if (delta.content) {
|
||||
yield { type: "text", text: delta.content }
|
||||
=======
|
||||
// OpenRouter passes reasoning details that we can pass back unmodified in api requests to preserve reasoning traces for model
|
||||
// See: https://openrouter.ai/docs/use-cases/reasoning-tokens#preserving-reasoning-blocks
|
||||
if (delta && "reasoning_details" in delta && delta.reasoning_details) {
|
||||
yield {
|
||||
type: "reasoning_details",
|
||||
reasoning_details: delta.reasoning_details as ReasoningDetail,
|
||||
}
|
||||
}
|
||||
|
||||
if ("reasoning" in delta && delta.reasoning && typeof delta.reasoning === "string") {
|
||||
yield { type: "reasoning", text: delta.reasoning }
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2147,12 +2147,8 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
// limit error, which gets thrown on the first chunk).
|
||||
const stream = this.attemptApiRequest()
|
||||
let assistantMessage = ""
|
||||
const reasoningDetails: ReasoningDetail[] = []
|
||||
let reasoningMessage = ""
|
||||
<<<<<<< HEAD
|
||||
const reasoningDetails: any[] = []
|
||||
=======
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
const reasoningDetails: ReasoningDetail[] = []
|
||||
let pendingGroundingSources: GroundingSource[] = []
|
||||
this.isStreaming = true
|
||||
|
||||
|
|
@ -2639,19 +2635,10 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
const assistantContent: Array<Anthropic.TextBlockParam | Anthropic.ToolUseBlockParam> = []
|
||||
|
||||
// Add text content if present
|
||||
<<<<<<< HEAD
|
||||
if (finalAssistantMessage) {
|
||||
assistantContent.push({
|
||||
type: "text" as const,
|
||||
text: finalAssistantMessage,
|
||||
=======
|
||||
if (finalAssistantMessage || reasoningDetails.length > 0) {
|
||||
assistantContent.push({
|
||||
type: "text" as const,
|
||||
text: finalAssistantMessage,
|
||||
// @ts-ignore-next-line OpenRouter-specific property
|
||||
reasoning_details: reasoningDetails.length > 0 ? reasoningDetails : undefined,
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -2662,10 +2649,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
const toolCallId = (toolUse as any).id
|
||||
if (toolCallId) {
|
||||
// nativeArgs is already in the correct API format for all tools
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
// @ts-ignore-next-line
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
const input = toolUse.nativeArgs || toolUse.params
|
||||
|
||||
assistantContent.push({
|
||||
|
|
@ -2676,10 +2659,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
})
|
||||
}
|
||||
}
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
await this.addToApiConversationHistory({
|
||||
role: "assistant",
|
||||
content: assistantContent.map((block) => {
|
||||
|
|
@ -3135,9 +3115,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
|
||||
const messagesSinceLastSummary = getMessagesSinceLastSummary(this.apiConversationHistory)
|
||||
const messagesWithoutImages = maybeRemoveImageBlocks(messagesSinceLastSummary, this.api)
|
||||
<<<<<<< HEAD
|
||||
const cleanConversationHistory = this.buildCleanConversationHistory(messagesWithoutImages as ApiMessage[])
|
||||
=======
|
||||
const messagesWithoutReasoningDetails = maybeRemoveReasoningDetails(
|
||||
messagesWithoutImages as ApiMessage[],
|
||||
apiConfiguration?.apiProvider,
|
||||
|
|
@ -3150,7 +3127,6 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
// Given the conflict, I will use the upstream logic but apply the reasoning details removal from stashed changes.
|
||||
|
||||
let cleanConversationHistory = messagesWithoutReasoningDetails.map(({ role, content }) => ({ role, content }))
|
||||
>>>>>>> 01c77f5c6 (Merge branch 'pr-9127-base' into feature/pr-9127-extended and resolve conflicts)
|
||||
|
||||
// Check auto-approval limits
|
||||
const approvalResult = await this.autoApprovalHandler.checkAutoApprovalLimits(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue