Bug fixes for openai provider

This commit is contained in:
Saoud Rizwan
2024-09-03 19:22:52 -04:00
parent 8274e89eac
commit cceebdc04c
6 changed files with 19 additions and 16 deletions

View File

@@ -917,7 +917,7 @@ export class ClaudeDev {
} as ClaudeSayTool) } as ClaudeSayTool)
) )
return `The user accepted but made the following changes to your content:\n\n${userDiff}\n\nFinal result ${ return `The user accepted but made the following changes to your content:\n\n${userDiff}\n\nFinal result ${
fileExists ? "applied to" : "written as new file" fileExists ? "saved to" : "written as new file"
} ${relPath}:\n\n${diffResult}` } ${relPath}:\n\n${diffResult}`
} else { } else {
const diffResult = diff.createPatch(relPath, originalContent, newContent) const diffResult = diff.createPatch(relPath, originalContent, newContent)

View File

@@ -73,7 +73,7 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({ showModelOptions, apiErrorMessa
id="api-provider" id="api-provider"
value={selectedProvider} value={selectedProvider}
onChange={handleInputChange("apiProvider")} onChange={handleInputChange("apiProvider")}
style={{ minWidth: 125 }}> style={{ minWidth: 130 }}>
<VSCodeOption value="anthropic">Anthropic</VSCodeOption> <VSCodeOption value="anthropic">Anthropic</VSCodeOption>
<VSCodeOption value="openrouter">OpenRouter</VSCodeOption> <VSCodeOption value="openrouter">OpenRouter</VSCodeOption>
<VSCodeOption value="bedrock">AWS Bedrock</VSCodeOption> <VSCodeOption value="bedrock">AWS Bedrock</VSCodeOption>
@@ -294,9 +294,8 @@ const ApiOptions: React.FC<ApiOptionsProps> = ({ showModelOptions, apiErrorMessa
}}> }}>
You can use any OpenAI compatible API with models that support tool use.{" "} You can use any OpenAI compatible API with models that support tool use.{" "}
<span style={{ color: "var(--vscode-errorForeground)" }}> <span style={{ color: "var(--vscode-errorForeground)" }}>
(<span style={{ fontWeight: 500 }}>Note:</span> Claude Dev uses complex prompts, so results (<span style={{ fontWeight: 500 }}>Note:</span> Claude Dev uses complex prompts, so less
may vary depending on the quality of the model you choose. Less capable models may not work capable models may not work as expected.)
as expected.)
</span> </span>
</p> </p>
</div> </div>

View File

@@ -93,7 +93,7 @@ const ChatRow: React.FC<ChatRowProps> = ({
] ]
case "api_req_started": case "api_req_started":
return [ return [
cost ? ( cost != null ? (
<span <span
className="codicon codicon-check" className="codicon codicon-check"
style={{ color: successColor, marginBottom: "-1.5px" }}></span> style={{ color: successColor, marginBottom: "-1.5px" }}></span>
@@ -104,7 +104,7 @@ const ChatRow: React.FC<ChatRowProps> = ({
) : ( ) : (
ProgressIndicator ProgressIndicator
), ),
cost ? ( cost != null ? (
<span style={{ color: normalColor, fontWeight: "bold" }}>API Request Complete</span> <span style={{ color: normalColor, fontWeight: "bold" }}>API Request Complete</span>
) : apiRequestFailedMessage ? ( ) : apiRequestFailedMessage ? (
<span style={{ color: errorColor, fontWeight: "bold" }}>API Request Failed</span> <span style={{ color: errorColor, fontWeight: "bold" }}>API Request Failed</span>
@@ -266,7 +266,9 @@ const ChatRow: React.FC<ChatRowProps> = ({
<div style={{ display: "flex", alignItems: "center", gap: "10px" }}> <div style={{ display: "flex", alignItems: "center", gap: "10px" }}>
{icon} {icon}
{title} {title}
{cost && <VSCodeBadge>${Number(cost)?.toFixed(4)}</VSCodeBadge>} {cost != null && cost > 0 && (
<VSCodeBadge>${Number(cost)?.toFixed(4)}</VSCodeBadge>
)}
</div> </div>
<VSCodeButton <VSCodeButton
appearance="icon" appearance="icon"

View File

@@ -108,12 +108,12 @@ const HistoryPreview = ({ showHistoryView }: HistoryPreviewProps) => {
<span> <span>
Tokens: {item.tokensIn?.toLocaleString()} {item.tokensOut?.toLocaleString()} Tokens: {item.tokensIn?.toLocaleString()} {item.tokensOut?.toLocaleString()}
</span> </span>
{item.cacheWrites && item.cacheReads && ( {!!item.cacheWrites && (
<> <>
{" • "} {" • "}
<span> <span>
Cache: +{item.cacheWrites?.toLocaleString()} {" "} Cache: +{item.cacheWrites?.toLocaleString()} {" "}
{item.cacheReads?.toLocaleString()} {(item.cacheReads || 0).toLocaleString()}
</span> </span>
</> </>
)} )}

View File

@@ -65,12 +65,13 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
const ExportButton = ({ itemId }: { itemId: string }) => ( const ExportButton = ({ itemId }: { itemId: string }) => (
<VSCodeButton <VSCodeButton
className="export-button"
appearance="icon" appearance="icon"
onClick={(e) => { onClick={(e) => {
e.stopPropagation() e.stopPropagation()
handleExportMd(itemId) handleExportMd(itemId)
}}> }}>
<div style={{ fontSize: "11px", fontWeight: 500, opacity: 1 }}>EXPORT .MD</div> <div style={{ fontSize: "11px", fontWeight: 500, opacity: 1 }}>EXPORT</div>
</VSCodeButton> </VSCodeButton>
) )
@@ -81,11 +82,12 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
.history-item:hover { .history-item:hover {
background-color: var(--vscode-list-hoverBackground); background-color: var(--vscode-list-hoverBackground);
} }
.delete-button { .delete-button, .export-button {
opacity: 0; opacity: 0;
pointer-events: none; pointer-events: none;
} }
.history-item:hover .delete-button { .history-item:hover .delete-button,
.history-item:hover .export-button {
opacity: 1; opacity: 1;
pointer-events: auto; pointer-events: auto;
} }
@@ -282,7 +284,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
{!item.totalCost && <ExportButton itemId={item.id} />} {!item.totalCost && <ExportButton itemId={item.id} />}
</div> </div>
{item.cacheWrites && item.cacheReads && ( {!!item.cacheWrites && (
<div <div
style={{ style={{
display: "flex", display: "flex",
@@ -329,7 +331,7 @@ const HistoryView = ({ onDone }: HistoryViewProps) => {
marginBottom: 0, marginBottom: 0,
}} }}
/> />
{item.cacheReads?.toLocaleString()} {(item.cacheReads || 0).toLocaleString()}
</span> </span>
</div> </div>
)} )}

View File

@@ -103,7 +103,7 @@ const TaskHeader: React.FC<TaskHeaderProps> = ({
marginBottom: "-2px", marginBottom: "-2px",
marginRight: "-2.5px", marginRight: "-2.5px",
}}> }}>
<div style={{ fontSize: "10.5px", fontWeight: "bold", opacity: 0.6 }}>EXPORT .MD</div> <div style={{ fontSize: "10.5px", fontWeight: "bold", opacity: 0.6 }}>EXPORT</div>
</VSCodeButton> </VSCodeButton>
) )