File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
js/packages/openinference-instrumentation-langchain/src Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -497,12 +497,19 @@ function formatPromptTemplate(run: Run): PromptTemplateAttributes | null {
497497function getTokenCount ( maybeCount : unknown ) {
498498 return isNumber ( maybeCount ) ? maybeCount : undefined ;
499499}
500+
500501/**
501- * A simple function that determines if a string is JSON like
502- * Note this is a rough check just to set the MIME type
502+ * A function that determines if a string is JSON like
503+ * @param str - The string to check
504+ * @returns true if the string is JSON
503505 */
504506function isJSONString ( str : string ) {
505- return str . startsWith ( "{" ) && str . endsWith ( "}" ) ;
507+ try {
508+ JSON . parse ( str ) ;
509+ return true ;
510+ } catch {
511+ return false ;
512+ }
506513}
507514
508515/**
You can’t perform that action at this time.
0 commit comments