You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{BasePromptElementProps,HTMLTracer,IChatEndpointInfo,PromptElementCtor,PromptRenderer,PromptSizing,RenderPromptResult,toVsCodeChatMessages}from"@vscode/prompt-tsx";import{AnyTokenizer}from"@vscode/prompt-tsx/dist/base/tokenizer/tokenizer";import{CancellationToken,ExtensionMode,LanguageModelChat,LanguageModelChatMessage,LanguageModelToolInvocationOptions,ProgressLocation,window}from"vscode";lettracingEnabled=false;exportfunctiontoggleTracing(extensionMode: ExtensionMode){if(extensionMode===ExtensionMode.Development){tracingEnabled=!tracingEnabled;}returntracingEnabled;}exportasyncfunctionrenderPrompt<PextendsBasePromptElementProps>(endpoint: IChatEndpointInfo,ctor: PromptElementCtor<P,any>,props: P,model: LanguageModelChat,token: CancellationToken){constrenderer=newPromptRenderer(endpoint,ctor,props,newAnyTokenizer(model.countTokens));letresult: RenderPromptResult;if(tracingEnabled){consttracer=newHTMLTracer();renderer.tracer=tracer;result=awaitrenderer.render(undefined,token);constserver=awaittracer.serveHTML();awaitwindow.withProgress({location: ProgressLocation.Notification,title: `Tracer server running at ${server.address}`,cancellable: true},async(progress,token)=>{awaitnewPromise<void>(resolve=>{constdispose=token.onCancellationRequested(()=>{dispose.dispose();server.dispose();resolve();});});});}else{result=awaitrenderer.render(undefined,token);}return{messages: toVsCodeChatMessages(result.messages)asLanguageModelChatMessage[],references: result.references};}
That can be used when debugging my extension and running the Toggle Prompt Tracing command. To start a server every time I render a prompt so I can inspect it.
It would be cool to have something like this baked into prompt-tsx. Maybe it could remember the last X prompts and just kick in automatically when debugging an extension. It could log the address to the debug console or something.
In short, lets make tracing really easy to get so debugging these prompts doesn't have to be so hard. It's a big sell for prompt-tsx.
The text was updated successfully, but these errors were encountered:
I wrote this fun helper:
That can be used when debugging my extension and running the
Toggle Prompt Tracing
command. To start a server every time I render a prompt so I can inspect it.It would be cool to have something like this baked into prompt-tsx. Maybe it could remember the last X prompts and just kick in automatically when debugging an extension. It could log the address to the debug console or something.
In short, lets make tracing really easy to get so debugging these prompts doesn't have to be so hard. It's a big sell for prompt-tsx.
The text was updated successfully, but these errors were encountered: