diff --git a/docs.json b/docs.json index 6604edcd21..ed71af9c11 100644 --- a/docs.json +++ b/docs.json @@ -1202,20 +1202,14 @@ { "group": "Classes", "pages": [ - "weave/reference/typescript-sdk/classes/conversation", "weave/reference/typescript-sdk/classes/dataset", "weave/reference/typescript-sdk/classes/evaluation", "weave/reference/typescript-sdk/classes/evaluationlogger", - "weave/reference/typescript-sdk/classes/llm", "weave/reference/typescript-sdk/classes/messagesprompt", "weave/reference/typescript-sdk/classes/objectref", "weave/reference/typescript-sdk/classes/scorelogger", "weave/reference/typescript-sdk/classes/stringprompt", - "weave/reference/typescript-sdk/classes/subagent", - "weave/reference/typescript-sdk/classes/tool", - "weave/reference/typescript-sdk/classes/turn", "weave/reference/typescript-sdk/classes/weaveadkplugin", - "weave/reference/typescript-sdk/classes/weaveclient", "weave/reference/typescript-sdk/classes/weaveobject" ] }, @@ -1226,12 +1220,10 @@ "weave/reference/typescript-sdk/functions/createotelextension", "weave/reference/typescript-sdk/functions/endconversation", "weave/reference/typescript-sdk/functions/endllm", - "weave/reference/typescript-sdk/functions/endsession", "weave/reference/typescript-sdk/functions/endturn", "weave/reference/typescript-sdk/functions/flushotel", "weave/reference/typescript-sdk/functions/getcurrentconversation", "weave/reference/typescript-sdk/functions/getcurrentllm", - "weave/reference/typescript-sdk/functions/getcurrentsession", "weave/reference/typescript-sdk/functions/getcurrentturn", "weave/reference/typescript-sdk/functions/instrumentopenaiagents", "weave/reference/typescript-sdk/functions/login", @@ -1242,7 +1234,6 @@ "weave/reference/typescript-sdk/functions/runisolated", "weave/reference/typescript-sdk/functions/startconversation", "weave/reference/typescript-sdk/functions/startllm", - "weave/reference/typescript-sdk/functions/startsession", "weave/reference/typescript-sdk/functions/startsubagent", "weave/reference/typescript-sdk/functions/starttool", "weave/reference/typescript-sdk/functions/startturn", @@ -1259,6 +1250,7 @@ "pages": [ "weave/reference/typescript-sdk/interfaces/callschema", "weave/reference/typescript-sdk/interfaces/callsfilter", + "weave/reference/typescript-sdk/interfaces/conversation", "weave/reference/typescript-sdk/interfaces/conversationinit", "weave/reference/typescript-sdk/interfaces/getagentsoptions", "weave/reference/typescript-sdk/interfaces/getagentspansoptions", @@ -1268,16 +1260,21 @@ "weave/reference/typescript-sdk/interfaces/getcallsoptions", "weave/reference/typescript-sdk/interfaces/httpresponse", "weave/reference/typescript-sdk/interfaces/httpvalidationerror", + "weave/reference/typescript-sdk/interfaces/llm", "weave/reference/typescript-sdk/interfaces/llminit", "weave/reference/typescript-sdk/interfaces/message", "weave/reference/typescript-sdk/interfaces/query", "weave/reference/typescript-sdk/interfaces/reasoning", "weave/reference/typescript-sdk/interfaces/sortby", + "weave/reference/typescript-sdk/interfaces/subagent", "weave/reference/typescript-sdk/interfaces/subagentinit", + "weave/reference/typescript-sdk/interfaces/tool", "weave/reference/typescript-sdk/interfaces/toolinit", + "weave/reference/typescript-sdk/interfaces/turn", "weave/reference/typescript-sdk/interfaces/turninit", "weave/reference/typescript-sdk/interfaces/usage", "weave/reference/typescript-sdk/interfaces/weaveaudio", + "weave/reference/typescript-sdk/interfaces/weaveclient", "weave/reference/typescript-sdk/interfaces/weaveimage" ] }, @@ -1301,9 +1298,18 @@ "weave/reference/typescript-sdk/type-aliases/response", "weave/reference/typescript-sdk/type-aliases/role", "weave/reference/typescript-sdk/type-aliases/session", + "weave/reference/typescript-sdk/type-aliases/session-1", "weave/reference/typescript-sdk/type-aliases/sessioninit", "weave/reference/typescript-sdk/type-aliases/settings" ] + }, + { + "group": "Variables", + "pages": [ + "weave/reference/typescript-sdk/variables/endsession", + "weave/reference/typescript-sdk/variables/getcurrentsession", + "weave/reference/typescript-sdk/variables/startsession" + ] } ] }, @@ -7597,4 +7603,4 @@ "stylesheet": "/css/styles.css" }, "theme": "aspen" -} \ No newline at end of file +} diff --git a/scripts/reference-generation/weave/generate_typescript_sdk_docs.py b/scripts/reference-generation/weave/generate_typescript_sdk_docs.py index a4573d24db..f5e6c04004 100755 --- a/scripts/reference-generation/weave/generate_typescript_sdk_docs.py +++ b/scripts/reference-generation/weave/generate_typescript_sdk_docs.py @@ -48,11 +48,16 @@ def download_weave_source(version="main"): text=True, check=True ) - # Parse the output to get the latest version tag + # Parse the output to get the latest version tag. The weave repo + # tags Python releases as vX.Y.Z and TypeScript SDK releases as + # vX.Y.Z-ts; only -ts tags correspond to npm releases of the SDK + # documented here, so anything else must be skipped (a newer + # Python tag would otherwise win the sort and document + # unreleased TS APIs). for line in result.stdout.strip().split('\n'): if '\trefs/tags/' in line and not line.endswith('^{}'): tag = line.split('\trefs/tags/')[-1] - if tag.startswith('v') and not 'dev' in tag and not 'rc' in tag: + if tag.startswith('v') and tag.endswith('-ts') and not 'dev' in tag and not 'rc' in tag: version = tag print(f" Using latest release: {version}") break @@ -124,8 +129,8 @@ def setup_typescript_project(weave_source): print(" Installing typedoc...") subprocess.run([ "npm", "install", "--save-dev", "--legacy-peer-deps", - "typedoc@0.25.13", - "typedoc-plugin-markdown@3.17.1" + "typedoc@0.28.20", + "typedoc-plugin-markdown@4.12.0" ], check=True) print(" ✓ Dependencies installed") @@ -154,7 +159,15 @@ def generate_typedoc(sdk_path, output_path): "excludeInternal": True, "disableSources": False, "cleanOutputDir": True, - "hideBreadcrumbs": True + "hideBreadcrumbs": True, + # The Weave repo currently ships a type error in the googleAdk + # integration (duplicate @google/genai versions in its dependency + # tree). Docs generation doesn't require the project to type-check, + # so don't let that abort the build. + "skipErrorChecking": True, + # typedoc-plugin-markdown v4 also prepends a bold package-name + # header to every page; Mintlify provides its own page chrome. + "hidePageHeader": True } config_path = sdk_path / "typedoc.json" @@ -175,6 +188,107 @@ def generate_typedoc(sdk_path, output_path): config_path.unlink() +def _escape_mdx_hostile_chars(content): + """Escape raw `<`, `{`, and `}` in prose so MDX doesn't parse them as JSX. + + TypeDoc escapes these in the output it generates itself, but comment text + inherited from third-party .d.ts files passes through verbatim (e.g. + @google/adk ships a corrupted doc comment containing raw code, which + TypeDoc 0.28 inherits onto WeaveAdkPlugin's members via its `implements` + clause). Fenced code blocks and inline code spans are left untouched; + already-escaped characters are not double-escaped. + """ + out_lines = [] + in_fence = False + for line in content.split('\n'): + if line.lstrip().startswith('```'): + in_fence = not in_fence + out_lines.append(line) + continue + if in_fence: + out_lines.append(line) + continue + # Even indices are prose; odd indices are inline code spans. + parts = re.split(r'(``[^`]*``|`[^`]*`)', line) + for i in range(0, len(parts), 2): + p = re.sub(r'(? (?:`[a-z]+` )*`optional` )', + r'\1\2\n\n', + content, + ) + # The bold name inside the signature line itself. + content = re.sub( + r'(?m)^(> (?:`[a-z]+` )*`optional` \*\*[^*\n]+?)\?((?:~~)?\*\*)', + r'\1\2', + content, + ) + return content + + +def _move_source_links_after_description(content): + """Move `Defined in: [...]` lines below the member's description. + + v4 places the source link between the signature and the description + text, so the description — the thing readers actually want — gets + pushed below the metadata. Relocate each source link to the end of its + block (just before the next heading, `***` separator, or end of file), + restoring the v3-era reading order: signature, description, source. + """ + lines = content.split('\n') + out = [] + pending = None + skip_blank = False + in_fence = False + + def flush(): + nonlocal pending + if pending is not None: + if out and out[-1] != '': + out.append('') + out.append(pending) + out.append('') + pending = None + + for line in lines: + if line.lstrip().startswith('```'): + in_fence = not in_fence + if not in_fence: + if skip_blank and line == '': + skip_blank = False + continue + skip_blank = False + if line.startswith('Defined in: ['): + flush() # consecutive source links (overloads): keep order + pending = line + skip_blank = True + continue + if pending is not None and (line.startswith('#') or line == '***'): + flush() + out.append(line) + flush() + return '\n'.join(out) + + def convert_to_mintlify_format(docs_dir): """Convert TypeDoc markdown to Mintlify MDX format.""" print(f"\nConverting to Mintlify format...") @@ -204,13 +318,32 @@ def convert_to_mintlify_format(docs_dir): # Fix escaped angle brackets in title (TypeDoc escapes them as \< and \>) title_fixed = title.replace('\\<', '<').replace('\\>', '>') + # typedoc-plugin-markdown v4 wraps deprecated symbols' titles in + # strikethrough (`# ~~Variable: startSession~~`); the deprecation is + # surfaced via the hoisted callout instead. + title_fixed = title_fixed.replace('~~', '') + # Strip TypeDoc's reflection-kind prefix ("Class: LLM" → "LLM") so the # left nav shows bare symbol names; the nav group already conveys the kind. + # v4 writes "Type Alias"; v3 wrote "Type alias". title_fixed = re.sub( - r'^(?:Class|Interface|Function|Type alias|Enumeration|Namespace|Variable|Module):\s+', + r'^(?:Class|Interface|Function|Type [Aa]lias|Enumeration|Namespace|Variable|Module):\s+', '', title_fixed, ) + + # v4 suffixes function/method titles with call parens ("login()"); + # drop them to keep bare symbol names in the nav. + title_fixed = re.sub(r'\(\)$', '', title_fixed) + + # Escape MDX-hostile characters in the body before the frontmatter is + # prepended (the quoted YAML title must keep its bare < and >). + content = _escape_mdx_hostile_chars(content) + + # De-duplicate v4's optional markers and restore the + # signature → description → source-link reading order. + content = _strip_redundant_optional_markers(content) + content = _move_source_links_after_description(content) # Add Mintlify frontmatter frontmatter = f"""--- @@ -256,15 +389,18 @@ def convert_to_mintlify_format(docs_dir): content = re.sub(r'\]\(\.\./interfaces/([^)#]+)(#[^)]+)?\)', lambda m: f'](../interfaces/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(\.\./functions/([^)#]+)(#[^)]+)?\)', lambda m: f'](../functions/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(\.\./type-aliases/([^)#]+)(#[^)]+)?\)', lambda m: f'](../type-aliases/{m.group(1).lower()}{m.group(2) or ""})', content) - + content = re.sub(r'\]\(\.\./variables/([^)#]+)(#[^)]+)?\)', lambda m: f'](../variables/{m.group(1).lower()}{m.group(2) or ""})', content) + # 4. Fix relative links without ../ prefix (same directory or subdirectory) content = re.sub(r'\]\(classes/([^)#]+)(#[^)]+)?\)', lambda m: f'](../classes/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(interfaces/([^)#]+)(#[^)]+)?\)', lambda m: f'](../interfaces/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(functions/([^)#]+)(#[^)]+)?\)', lambda m: f'](../functions/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(type-aliases/([^)#]+)(#[^)]+)?\)', lambda m: f'](../type-aliases/{m.group(1).lower()}{m.group(2) or ""})', content) - + content = re.sub(r'\]\(variables/([^)#]+)(#[^)]+)?\)', lambda m: f'](../variables/{m.group(1).lower()}{m.group(2) or ""})', content) + # 5. Fix same-directory class/interface links (start with capital letter, no path separator) - content = re.sub(r'\]\(([A-Z][a-zA-Z]+)(#[^)]+)?\)', lambda m: f'](./{m.group(1).lower()}{m.group(2) or ""})', content) + # Allow digits and hyphens for TypeDoc's name-collision suffixes (e.g. Session-1) + content = re.sub(r'\]\(([A-Z][a-zA-Z0-9-]+)(#[^)]+)?\)', lambda m: f'](./{m.group(1).lower()}{m.group(2) or ""})', content) # 6. Special fix for README/landing page - it becomes typescript-sdk.mdx at parent level if md_file.name == 'README.md': @@ -274,7 +410,8 @@ def convert_to_mintlify_format(docs_dir): content = re.sub(r'\]\(\.\./interfaces/([^)#]+)(#[^)]+)?\)', lambda m: f'](./typescript-sdk/interfaces/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(\.\./functions/([^)#]+)(#[^)]+)?\)', lambda m: f'](./typescript-sdk/functions/{m.group(1).lower()}{m.group(2) or ""})', content) content = re.sub(r'\]\(\.\./type-aliases/([^)#]+)(#[^)]+)?\)', lambda m: f'](./typescript-sdk/type-aliases/{m.group(1).lower()}{m.group(2) or ""})', content) - + content = re.sub(r'\]\(\.\./variables/([^)#]+)(#[^)]+)?\)', lambda m: f'](./typescript-sdk/variables/{m.group(1).lower()}{m.group(2) or ""})', content) + # Fix self-referential anchor links like (README#anchor) that appear in Table of Contents # We'll scan the content to determine if each anchor refers to a function or type alias # First, extract all type alias names (they have the Ƭ symbol) @@ -638,23 +775,34 @@ def organize_for_mintlify(temp_output, final_output): print(" ✓ Documentation organized") -# Matches TypeDoc's @deprecated output: -# `Deprecated` +# Matches TypeDoc's @deprecated output. typedoc-plugin-markdown v4 renders it +# as a heading section whose level depends on nesting depth (`## Deprecated` +# at page level, `#### Deprecated` under a member, `##### Deprecated` under an +# accessor signature): +# ## Deprecated # # # -# Stops at the next heading or `___` separator (or end of file). The non-greedy -# `.+?` plus the lookahead lets the message itself span multiple soft-wrapped -# lines without swallowing the section that follows it. +# (v3 rendered an inline `` `Deprecated` `` label instead; that form is also +# still matched.) Stops at the next heading or `***`/`___` separator (or end +# of file). The non-greedy `.+?` plus the lookahead lets the message itself +# span multiple soft-wrapped lines without swallowing the section that +# follows it. _DEPRECATED_BLOCK_RE = re.compile( - r'\n\n`Deprecated`\n\n(.+?)(?=\n\n(?:#{1,6} |___|\Z))', + r'\n\n(?:(#{2,5}) Deprecated|`Deprecated`)\n\n(.+?)(?=\n\n(?:#{1,6} |\*\*\*|___)|\n*\Z)', re.DOTALL, ) # Symbol-level headings only. H4 (`#### Returns`, `#### Defined in`) is a # *sub*section of a symbol and is deliberately excluded — anchoring the -# warning there would put it back where TypeDoc already placed it. -_SYMBOL_HEADING_RE = re.compile(r'^#{1,3} .+$', re.MULTILINE) +# warning there would put it back where TypeDoc already placed it. The +# `Deprecated` headings themselves are excluded too: they belong to the very +# blocks being removed, so anchoring a later warning to one would insert +# text into a deleted span. +_SYMBOL_HEADING_RE = re.compile(r'^#{1,3} (?!Deprecated$).+$', re.MULTILINE) + +# Frontmatter block at the very start of a converted .mdx file. +_FRONTMATTER_RE = re.compile(r'\A---\n.*?\n---\n', re.DOTALL) def hoist_deprecation_callouts(docs_root): @@ -691,21 +839,42 @@ def _hoist_deprecations_in_text(content): headings = list(_SYMBOL_HEADING_RE.finditer(content)) + # A page-level deprecation can precede every heading (the H1 was already + # moved into frontmatter during conversion), so the fallback anchor must + # sit after the frontmatter, never at position 0. + fm = _FRONTMATTER_RE.match(content) + default_anchor = fm.end() if fm else 0 + edits = [] inserts_by_pos = {} for dep in deprecations: - message = dep.group(1).strip() + message = dep.group(2).strip() warning = f'\n\n\n **Deprecated.** {message}\n' - anchor = 0 - for h in headings: - if h.start() < dep.start(): - anchor = h.end() - else: - break + # An `## Deprecated` (H2) section deprecates the page's own symbol — + # its H1 heading is already gone (moved into frontmatter), and any H2 + # headings preceding it (`## Parameters`, `## Examples`, ...) are + # sections of the same symbol, not other symbols. Hoist it to the top + # of the page. Deeper levels (H4/H5) belong to a member documented + # under an H2/H3 heading, so those anchor to the nearest one. + if dep.group(1) == '##': + anchor = default_anchor + else: + anchor = default_anchor + for h in headings: + if h.start() < dep.start(): + anchor = h.end() + else: + break edits.append((dep.start(), dep.end(), '')) + # Heading-anchored inserts land before the blank line that already + # follows the heading; a top-of-page insert lands right before the + # first content line, so it needs its own trailing blank line to + # keep the following markdown block separate from the JSX element. + if anchor == default_anchor: + warning += '\n' inserts_by_pos.setdefault(anchor, []).append(warning) for pos, warns in inserts_by_pos.items(): diff --git a/weave/reference/typescript-sdk.mdx b/weave/reference/typescript-sdk.mdx index ca5a142b99..806d5286cf 100644 --- a/weave/reference/typescript-sdk.mdx +++ b/weave/reference/typescript-sdk.mdx @@ -3,91 +3,88 @@ title: "weave" description: "TypeScript SDK reference" --- -## Table of contents +## Classes -### Classes - -- [Conversation](./typescript-sdk/classes/conversation) - [Dataset](./typescript-sdk/classes/dataset) - [Evaluation](./typescript-sdk/classes/evaluation) - [EvaluationLogger](./typescript-sdk/classes/evaluationlogger) -- [LLM](./typescript-sdk/classes/llm) - [MessagesPrompt](./typescript-sdk/classes/messagesprompt) - [ObjectRef](./typescript-sdk/classes/objectref) - [ScoreLogger](./typescript-sdk/classes/scorelogger) - [StringPrompt](./typescript-sdk/classes/stringprompt) -- [SubAgent](./typescript-sdk/classes/subagent) -- [Tool](./typescript-sdk/classes/tool) -- [Turn](./typescript-sdk/classes/turn) - [WeaveAdkPlugin](./typescript-sdk/classes/weaveadkplugin) -- [WeaveClient](./typescript-sdk/classes/weaveclient) - [WeaveObject](./typescript-sdk/classes/weaveobject) -### Interfaces +## Interfaces - [CallSchema](./typescript-sdk/interfaces/callschema) - [CallsFilter](./typescript-sdk/interfaces/callsfilter) +- [Conversation](./typescript-sdk/interfaces/conversation) - [ConversationInit](./typescript-sdk/interfaces/conversationinit) +- [GetAgentsOptions](./typescript-sdk/interfaces/getagentsoptions) - [GetAgentSpansOptions](./typescript-sdk/interfaces/getagentspansoptions) - [GetAgentTurnOptions](./typescript-sdk/interfaces/getagentturnoptions) - [GetAgentTurnsOptions](./typescript-sdk/interfaces/getagentturnsoptions) - [GetAgentVersionsOptions](./typescript-sdk/interfaces/getagentversionsoptions) -- [GetAgentsOptions](./typescript-sdk/interfaces/getagentsoptions) - [GetCallsOptions](./typescript-sdk/interfaces/getcallsoptions) -- [HTTPValidationError](./typescript-sdk/interfaces/httpvalidationerror) - [HttpResponse](./typescript-sdk/interfaces/httpresponse) +- [HTTPValidationError](./typescript-sdk/interfaces/httpvalidationerror) +- [LLM](./typescript-sdk/interfaces/llm) - [LLMInit](./typescript-sdk/interfaces/llminit) - [Message](./typescript-sdk/interfaces/message) - [Query](./typescript-sdk/interfaces/query) - [Reasoning](./typescript-sdk/interfaces/reasoning) - [SortBy](./typescript-sdk/interfaces/sortby) +- [SubAgent](./typescript-sdk/interfaces/subagent) - [SubAgentInit](./typescript-sdk/interfaces/subagentinit) +- [Tool](./typescript-sdk/interfaces/tool) - [ToolInit](./typescript-sdk/interfaces/toolinit) +- [Turn](./typescript-sdk/interfaces/turn) - [TurnInit](./typescript-sdk/interfaces/turninit) - [Usage](./typescript-sdk/interfaces/usage) - [WeaveAudio](./typescript-sdk/interfaces/weaveaudio) +- [WeaveClient](./typescript-sdk/interfaces/weaveclient) - [WeaveImage](./typescript-sdk/interfaces/weaveimage) +## Type Aliases -### Type Aliases - +- [Agent](./typescript-sdk/type-aliases/agent) - [AgentMessage](./typescript-sdk/type-aliases/agentmessage) - [AgentSpan](./typescript-sdk/type-aliases/agentspan) - [AgentTurn](./typescript-sdk/type-aliases/agentturn) - [AgentVersion](./typescript-sdk/type-aliases/agentversion) -- [Agent](./typescript-sdk/type-aliases/agent) - [GetAgentSpansResult](./typescript-sdk/type-aliases/getagentspansresult) +- [GetAgentsResult](./typescript-sdk/type-aliases/getagentsresult) - [GetAgentTurnResult](./typescript-sdk/type-aliases/getagentturnresult) - [GetAgentTurnsResult](./typescript-sdk/type-aliases/getagentturnsresult) - [GetAgentVersionsResult](./typescript-sdk/type-aliases/getagentversionsresult) -- [GetAgentsResult](./typescript-sdk/type-aliases/getagentsresult) - [MessagePart](./typescript-sdk/type-aliases/messagepart) - [Modality](./typescript-sdk/type-aliases/modality) -- [OpDecorator](./typescript-sdk/type-aliases/opdecorator) - [Op](./typescript-sdk/type-aliases/op) +- [OpDecorator](./typescript-sdk/type-aliases/opdecorator) - [Response](./typescript-sdk/type-aliases/response) - [Role](./typescript-sdk/type-aliases/role) -- [SessionInit](./typescript-sdk/type-aliases/sessioninit) -- [Session](./typescript-sdk/type-aliases/session) +- [~~Session~~](./typescript-sdk/type-aliases/session) +- [~~Session~~](./typescript-sdk/type-aliases/session-1) +- [~~SessionInit~~](./typescript-sdk/type-aliases/sessioninit) - [Settings](./typescript-sdk/type-aliases/settings) -### Variables +## Variables -- [Session](#session) +- [~~endSession~~](./typescript-sdk/variables/endsession) +- [~~getCurrentSession~~](./typescript-sdk/variables/getcurrentsession) +- [~~startSession~~](./typescript-sdk/variables/startsession) - -### Functions +## Functions - [createOpenAIAgentsTracingProcessor](./typescript-sdk/functions/createopenaiagentstracingprocessor) - [createOtelExtension](./typescript-sdk/functions/createotelextension) - [endConversation](./typescript-sdk/functions/endconversation) - [endLLM](./typescript-sdk/functions/endllm) -- [endSession](./typescript-sdk/functions/endsession) - [endTurn](./typescript-sdk/functions/endturn) - [flushOTel](./typescript-sdk/functions/flushotel) - [getCurrentConversation](./typescript-sdk/functions/getcurrentconversation) - [getCurrentLLM](./typescript-sdk/functions/getcurrentllm) -- [getCurrentSession](./typescript-sdk/functions/getcurrentsession) - [getCurrentTurn](./typescript-sdk/functions/getcurrentturn) - [init](./typescript-sdk/functions/init) - [instrumentOpenAIAgents](./typescript-sdk/functions/instrumentopenaiagents) @@ -99,7 +96,6 @@ description: "TypeScript SDK reference" - [runIsolated](./typescript-sdk/functions/runisolated) - [startConversation](./typescript-sdk/functions/startconversation) - [startLLM](./typescript-sdk/functions/startllm) -- [startSession](./typescript-sdk/functions/startsession) - [startSubagent](./typescript-sdk/functions/startsubagent) - [startTool](./typescript-sdk/functions/starttool) - [startTurn](./typescript-sdk/functions/startturn) @@ -108,72 +104,4 @@ description: "TypeScript SDK reference" - [withAttributes](./typescript-sdk/functions/withattributes) - [wrapClaudeAgentSdk](./typescript-sdk/functions/wrapclaudeagentsdk) - [wrapGoogleGenAI](./typescript-sdk/functions/wrapgooglegenai) -- [wrapOpenAI](./typescript-sdk/functions/wrapopenai) - -## Type Aliases - - - - - - - - - - - - - - - - - - - - -### Session - - - **Deprecated.** Use [Conversation](./typescript-sdk/classes/conversation) instead. - - -• **Session**: typeof [`Conversation`](./typescript-sdk/classes/conversation) - -#### Defined in - -[src/genai/conversation.ts:191](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L191) - -[src/genai/conversation.ts:193](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L193) - -## Functions - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +- [wrapOpenAI](./typescript-sdk/functions/wrapopenai) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/conversation.mdx b/weave/reference/typescript-sdk/classes/conversation.mdx deleted file mode 100644 index ca99b1bc9d..0000000000 --- a/weave/reference/typescript-sdk/classes/conversation.mdx +++ /dev/null @@ -1,185 +0,0 @@ ---- -title: "Conversation" -description: "TypeScript SDK reference" ---- - -A Conversation groups Turns under a single `gen_ai.conversation.id`. It is -not itself an OTel span — children stamp the conversation id onto theirs. - -## Table of contents - -### Accessors - -- [agentName](./conversation#agentname) -- [attributes](./conversation#attributes) -- [conversationId](./conversation#conversationid) -- [model](./conversation#model) -- [sessionId](./conversation#sessionid) - -### Methods - -- [end](./conversation#end) -- [startTurn](./conversation#startturn) -- [create](./conversation#create) - -## Accessors - -### agentName - -• `get` **agentName**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/conversation.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L94) - -___ - -### attributes - -• `get` **attributes**(): `Attributes` - -#### Returns - -`Attributes` - -#### Defined in - -[src/genai/conversation.ts:106](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L106) - -___ - -### conversationId - -• `get` **conversationId**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/conversation.ts:102](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L102) - -___ - -### model - -• `get` **model**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/conversation.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L98) - -___ - -### sessionId - - - **Deprecated.** Use [Conversation.conversationId](./conversation#conversationid) instead. - - -• `get` **sessionId**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/conversation.ts:111](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L111) - -## Methods - -### end - -▸ **end**(`opts?`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | - -#### Returns - -`void` - -#### Defined in - -[src/genai/conversation.ts:168](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L168) - -___ - -### startTurn - -▸ **startTurn**(`opts?`): [`Turn`](./turn) - -Start a new `Turn` under this `Conversation`. The turn inherits the -conversation's `conversationId`; `agentName`, `agentId`, `agentDescription`, -`agentVersion` and `model` fall back to the conversation's values when not -provided on `opts`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`TurnInit`](../interfaces/turninit) | - -#### Returns - -[`Turn`](./turn) - -`Example` - -```ts twoslash -// @noErrors -const turn = conversation.startTurn(); -``` - -`Example` - -```ts twoslash -// @noErrors -const turn = conversation.startTurn({ - model: 'gpt-4o', - agentName: 'research-bot', - agentId: 'research-bot-prod', - agentDescription: 'Looks up facts on Wikipedia.', - agentVersion: '1.4.2', - userMessage: 'What is the weather in Tokyo?', - systemInstructions: ['You are a helpful weather bot.'], - startTime: new Date('2026-05-29T10:00:00.000Z'), -}); -``` - -#### Defined in - -[src/genai/conversation.ts:156](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L156) - -___ - -### create - -▸ **create**(`opts?`): [`Conversation`](./conversation) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`ConversationInit`](../interfaces/conversationinit) | - -#### Returns - -[`Conversation`](./conversation) - -#### Defined in - -[src/genai/conversation.ts:115](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L115) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/dataset.mdx b/weave/reference/typescript-sdk/classes/dataset.mdx index ab744e8080..d09e8f3111 100644 --- a/weave/reference/typescript-sdk/classes/dataset.mdx +++ b/weave/reference/typescript-sdk/classes/dataset.mdx @@ -5,7 +5,9 @@ description: "TypeScript SDK reference" Dataset object with easy saving and automatic versioning -`Example` +Defined in: [src/dataset.ts:52](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L52) + +## Example ```ts twoslash // @noErrors @@ -26,208 +28,162 @@ const exampleLabel = dataset.getRow(2).sentence; const ref = await dataset.save() ``` -## Type parameters - -| Name | Type | -| :------ | :------ | -| `R` | extends `DatasetRow` | - -## Hierarchy +## Extends - [`WeaveObject`](./weaveobject) - ↳ `Dataset` - -## Table of contents - -### Constructors - -- [constructor](./dataset#constructor) - -### Properties - -- [\_\_savedRef](./dataset#__savedref) -- [rows](./dataset#rows) - -### Accessors - -- [description](./dataset#description) -- [length](./dataset#length) -- [name](./dataset#name) +## Type Parameters -### Methods +### R -- [[asyncIterator]](./dataset#[asynciterator]) -- [getRow](./dataset#getrow) -- [save](./dataset#save) -- [saveAttrs](./dataset#saveattrs) +`R` *extends* `DatasetRow` ## Constructors -### constructor +### Constructor -• **new Dataset**\<`R`\>(`parameters`): [`Dataset`](./dataset)\<`R`\> +> **new Dataset**\<`R`\>(`parameters`): `Dataset`\<`R`\> -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `R` | extends `DatasetRow` | +Defined in: [src/dataset.ts:55](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L55) #### Parameters -| Name | Type | -| :------ | :------ | -| `parameters` | `DatasetParameters`\<`R`\> | +##### parameters + +`DatasetParameters`\<`R`\> #### Returns -[`Dataset`](./dataset)\<`R`\> +`Dataset`\<`R`\> #### Overrides -[WeaveObject](./weaveobject).[constructor](./weaveobject#constructor) - -#### Defined in - -[src/dataset.ts:55](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L55) +[`WeaveObject`](./weaveobject).[`constructor`](./weaveobject#constructor) ## Properties ### \_\_savedRef -• `Optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> +> `optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> -#### Inherited from +Defined in: [src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) -[WeaveObject](./weaveobject).[__savedRef](./weaveobject#__savedref) - -#### Defined in +#### Inherited from -[src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) +[`WeaveObject`](./weaveobject).[`__savedRef`](./weaveobject#__savedref) -___ +*** ### rows -• **rows**: `Table`\<`R`\> +> **rows**: `Table`\<`R`\> -#### Defined in - -[src/dataset.ts:53](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L53) +Defined in: [src/dataset.ts:53](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L53) ## Accessors ### description -• `get` **description**(): `undefined` \| `string` +#### Get Signature -#### Returns +> **get** **description**(): `string` \| `undefined` -`undefined` \| `string` +Defined in: [src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) -#### Inherited from +##### Returns -WeaveObject.description +`string` \| `undefined` -#### Defined in +#### Inherited from -[src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) +[`WeaveObject`](./weaveobject).[`description`](./weaveobject#description) -___ +*** ### length -• `get` **length**(): `number` +#### Get Signature -#### Returns +> **get** **length**(): `number` -`number` +Defined in: [src/dataset.ts:68](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L68) -#### Defined in +##### Returns -[src/dataset.ts:68](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L68) +`number` -___ +*** ### name -• `get` **name**(): `string` +#### Get Signature -#### Returns +> **get** **name**(): `string` -`string` +Defined in: [src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) -#### Inherited from +##### Returns -WeaveObject.name +`string` -#### Defined in +#### Inherited from -[src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) +[`WeaveObject`](./weaveobject).[`name`](./weaveobject#name) ## Methods -### [asyncIterator] +### \[asyncIterator\]() -▸ **[asyncIterator]**(): `AsyncIterator`\<`any`, `any`, `any`\> +> **\[asyncIterator\]**(): `AsyncIterator`\<`any`\> -#### Returns +Defined in: [src/dataset.ts:72](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L72) -`AsyncIterator`\<`any`, `any`, `any`\> +#### Returns -#### Defined in +`AsyncIterator`\<`any`\> -[src/dataset.ts:72](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L72) +*** -___ +### getRow() -### getRow +> **getRow**(`index`): `R` -▸ **getRow**(`index`): `R` +Defined in: [src/dataset.ts:78](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L78) #### Parameters -| Name | Type | -| :------ | :------ | -| `index` | `number` | +##### index + +`number` #### Returns `R` -#### Defined in +*** -[src/dataset.ts:78](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L78) +### save() -___ +> **save**(): `Promise`\<[`ObjectRef`](./objectref)\> -### save - -▸ **save**(): `Promise`\<[`ObjectRef`](./objectref)\> +Defined in: [src/dataset.ts:64](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L64) #### Returns `Promise`\<[`ObjectRef`](./objectref)\> -#### Defined in - -[src/dataset.ts:64](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/dataset.ts#L64) +*** -___ +### saveAttrs() -### saveAttrs +> **saveAttrs**(): `object` -▸ **saveAttrs**(): `Object` +Defined in: [src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) #### Returns -`Object` +`object` #### Inherited from -[WeaveObject](./weaveobject).[saveAttrs](./weaveobject#saveattrs) - -#### Defined in - -[src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) \ No newline at end of file +[`WeaveObject`](./weaveobject).[`saveAttrs`](./weaveobject#saveattrs) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/evaluation.mdx b/weave/reference/typescript-sdk/classes/evaluation.mdx index 6e3769f7f3..3538eaa7b1 100644 --- a/weave/reference/typescript-sdk/classes/evaluation.mdx +++ b/weave/reference/typescript-sdk/classes/evaluation.mdx @@ -10,7 +10,9 @@ the names of the columns of the dataset to the argument names in model.predict. Then it will call all of the scorers and save the results in weave. -`Example` +Defined in: [src/evaluation.ts:139](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L139) + +## Example ```ts twoslash // @noErrors @@ -44,183 +46,162 @@ const evaluation = new weave.Evaluation({ const results = await evaluation.evaluate({ model }); ``` -## Type parameters - -| Name | Type | -| :------ | :------ | -| `R` | extends `DatasetRow` | -| `E` | extends `DatasetRow` | -| `M` | `M` | - -## Hierarchy +## Extends - [`WeaveObject`](./weaveobject) - ↳ `Evaluation` - -## Table of contents - -### Constructors +## Type Parameters -- [constructor](./evaluation#constructor) +### R -### Properties +`R` *extends* `DatasetRow` -- [\_\_savedRef](./evaluation#__savedref) +### E -### Accessors +`E` *extends* `DatasetRow` -- [description](./evaluation#description) -- [name](./evaluation#name) +### M -### Methods - -- [evaluate](./evaluation#evaluate) -- [predictAndScore](./evaluation#predictandscore) -- [saveAttrs](./evaluation#saveattrs) +`M` ## Constructors -### constructor - -• **new Evaluation**\<`R`, `E`, `M`\>(`parameters`): [`Evaluation`](./evaluation)\<`R`, `E`, `M`\> +### Constructor -#### Type parameters +> **new Evaluation**\<`R`, `E`, `M`\>(`parameters`): `Evaluation`\<`R`, `E`, `M`\> -| Name | Type | -| :------ | :------ | -| `R` | extends `DatasetRow` | -| `E` | extends `DatasetRow` | -| `M` | `M` | +Defined in: [src/evaluation.ts:150](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L150) #### Parameters -| Name | Type | -| :------ | :------ | -| `parameters` | `EvaluationParameters`\<`R`, `E`, `M`\> | +##### parameters + +`EvaluationParameters`\<`R`, `E`, `M`\> #### Returns -[`Evaluation`](./evaluation)\<`R`, `E`, `M`\> +`Evaluation`\<`R`, `E`, `M`\> #### Overrides -[WeaveObject](./weaveobject).[constructor](./weaveobject#constructor) - -#### Defined in - -[src/evaluation.ts:150](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L150) +[`WeaveObject`](./weaveobject).[`constructor`](./weaveobject#constructor) ## Properties ### \_\_savedRef -• `Optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> +> `optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> -#### Inherited from - -[WeaveObject](./weaveobject).[__savedRef](./weaveobject#__savedref) +Defined in: [src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) -#### Defined in +#### Inherited from -[src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) +[`WeaveObject`](./weaveobject).[`__savedRef`](./weaveobject#__savedref) ## Accessors ### description -• `get` **description**(): `undefined` \| `string` +#### Get Signature -#### Returns +> **get** **description**(): `string` \| `undefined` -`undefined` \| `string` +Defined in: [src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) -#### Inherited from +##### Returns -WeaveObject.description +`string` \| `undefined` -#### Defined in +#### Inherited from -[src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) +[`WeaveObject`](./weaveobject).[`description`](./weaveobject#description) -___ +*** ### name -• `get` **name**(): `string` +#### Get Signature -#### Returns +> **get** **name**(): `string` -`string` +Defined in: [src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) -#### Inherited from +##### Returns -WeaveObject.name +`string` -#### Defined in +#### Inherited from -[src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) +[`WeaveObject`](./weaveobject).[`name`](./weaveobject#name) ## Methods -### evaluate +### evaluate() + +> **evaluate**(`__namedParameters`): `Promise`\<`Record`\<`string`, `any`\>\> -▸ **evaluate**(`«destructured»`): `Promise`\<`Record`\<`string`, `any`\>\> +Defined in: [src/evaluation.ts:165](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L165) #### Parameters -| Name | Type | Default value | -| :------ | :------ | :------ | -| `«destructured»` | `Object` | `undefined` | -| › `maxConcurrency?` | `number` | `5` | -| › `model` | `WeaveCallable`\<(...`args`: [\{ `datasetRow`: `R` }]) => `Promise`\<`M`\>\> | `undefined` | -| › `nTrials?` | `number` | `1` | +##### \_\_namedParameters + +###### maxConcurrency? + +`number` = `5` + +###### model + +`WeaveCallable`\<(...`args`) => `Promise`\<`M`\>\> + +###### nTrials? + +`number` = `1` #### Returns `Promise`\<`Record`\<`string`, `any`\>\> -#### Defined in - -[src/evaluation.ts:165](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L165) +*** -___ +### predictAndScore() -### predictAndScore +> **predictAndScore**(`__namedParameters`): `Promise`\<\{ `model_latency`: `number`; `model_output`: `any`; `model_success`: `boolean`; `scores`: \{\[`key`: `string`\]: `any`; \}; \}\> -▸ **predictAndScore**(`«destructured»`): `Promise`\<\{ `model_latency`: `number` = modelLatency; `model_output`: `any` = modelOutput; `model_success`: `boolean` = !modelError; `scores`: \{ `[key: string]`: `any`; } }\> +Defined in: [src/evaluation.ts:244](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L244) #### Parameters -| Name | Type | -| :------ | :------ | -| `«destructured»` | `Object` | -| › `columnMapping?` | `ColumnMapping`\<`R`, `E`\> | -| › `example` | `R` | -| › `model` | `WeaveCallable`\<(...`args`: [\{ `datasetRow`: `E` }]) => `Promise`\<`M`\>\> | +##### \_\_namedParameters -#### Returns - -`Promise`\<\{ `model_latency`: `number` = modelLatency; `model_output`: `any` = modelOutput; `model_success`: `boolean` = !modelError; `scores`: \{ `[key: string]`: `any`; } }\> +###### columnMapping? -#### Defined in +`ColumnMapping`\<`R`, `E`\> -[src/evaluation.ts:244](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluation.ts#L244) +###### example -___ +`R` -### saveAttrs +###### model -▸ **saveAttrs**(): `Object` +`WeaveCallable`\<(...`args`) => `Promise`\<`M`\>\> #### Returns -`Object` +`Promise`\<\{ `model_latency`: `number`; `model_output`: `any`; `model_success`: `boolean`; `scores`: \{\[`key`: `string`\]: `any`; \}; \}\> -#### Inherited from +*** + +### saveAttrs() + +> **saveAttrs**(): `object` -[WeaveObject](./weaveobject).[saveAttrs](./weaveobject#saveattrs) +Defined in: [src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) -#### Defined in +#### Returns + +`object` + +#### Inherited from -[src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) \ No newline at end of file +[`WeaveObject`](./weaveobject).[`saveAttrs`](./weaveobject#saveattrs) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/evaluationlogger.mdx b/weave/reference/typescript-sdk/classes/evaluationlogger.mdx index e950356283..02c354aa4c 100644 --- a/weave/reference/typescript-sdk/classes/evaluationlogger.mdx +++ b/weave/reference/typescript-sdk/classes/evaluationlogger.mdx @@ -8,7 +8,9 @@ EvaluationLogger enables incremental logging of predictions and scores. Unlike the traditional Evaluation class which requires upfront dataset and batch processing, EvaluationLogger allows you to log predictions as they happen, with flexible scoring. -`Example` +Defined in: [src/evaluationLogger.ts:554](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L554) + +## Example ```ts twoslash // @noErrors @@ -27,43 +29,29 @@ for (const example of streamingData) { await ev.logSummary(); ``` -## Table of contents - -### Constructors - -- [constructor](./evaluationlogger#constructor) - -### Methods - -- [logPrediction](./evaluationlogger#logprediction) -- [logPredictionAsync](./evaluationlogger#logpredictionasync) -- [logSummary](./evaluationlogger#logsummary) - ## Constructors -### constructor +### Constructor -• **new EvaluationLogger**(`options`): [`EvaluationLogger`](./evaluationlogger) +> **new EvaluationLogger**(`options`): `EvaluationLogger` -#### Parameters +Defined in: [src/evaluationLogger.ts:573](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L573) -| Name | Type | -| :------ | :------ | -| `options` | `EvaluationLoggerOptions` | +#### Parameters -#### Returns +##### options -[`EvaluationLogger`](./evaluationlogger) +`EvaluationLoggerOptions` -#### Defined in +#### Returns -[src/evaluationLogger.ts:573](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L573) +`EvaluationLogger` ## Methods -### logPrediction +### logPrediction() -▸ **logPrediction**(`inputs`, `output`): [`ScoreLogger`](./scorelogger) +> **logPrediction**(`inputs`, `output`): [`ScoreLogger`](./scorelogger) Log a prediction with its input and output (synchronous version). Creates a predict_and_score call (with child predict call). @@ -72,18 +60,23 @@ Returns a ScoreLogger immediately for adding scores. This method returns the ScoreLogger synchronously. Operations on the ScoreLogger (logScore, finish) will be queued and executed when initialization completes. +Defined in: [src/evaluationLogger.ts:660](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L660) + #### Parameters -| Name | Type | -| :------ | :------ | -| `inputs` | `Record`\<`string`, `any`\> | -| `output` | `any` | +##### inputs + +`Record`\<`string`, `any`\> + +##### output + +`any` #### Returns [`ScoreLogger`](./scorelogger) -`Example` +#### Example ```ts twoslash // @noErrors @@ -94,15 +87,11 @@ scoreLogger.finish(); await evalLogger.logSummary(); // Waits for everything ``` -#### Defined in - -[src/evaluationLogger.ts:660](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L660) +*** -___ +### logPredictionAsync() -### logPredictionAsync - -▸ **logPredictionAsync**(`inputs`, `output`): `Promise`\<[`ScoreLogger`](./scorelogger)\> +> **logPredictionAsync**(`inputs`, `output`): `Promise`\<[`ScoreLogger`](./scorelogger)\> Log a prediction with its input and output (async version). Like logPrediction() but returns a Promise that resolves when @@ -110,18 +99,23 @@ the prediction call is fully initialized. Use this if you need to await the initialization before proceeding. +Defined in: [src/evaluationLogger.ts:685](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L685) + #### Parameters -| Name | Type | -| :------ | :------ | -| `inputs` | `Record`\<`string`, `any`\> | -| `output` | `any` | +##### inputs + +`Record`\<`string`, `any`\> + +##### output + +`any` #### Returns `Promise`\<[`ScoreLogger`](./scorelogger)\> -`Example` +#### Example ```ts twoslash // @noErrors @@ -131,15 +125,11 @@ await scoreLogger.logScore('accuracy', 0.95); await scoreLogger.finish(); ``` -#### Defined in +*** -[src/evaluationLogger.ts:685](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L685) +### logSummary() -___ - -### logSummary - -▸ **logSummary**(`summary?`): `Promise`\<`void`\> +> **logSummary**(`summary?`): `Promise`\<`void`\> Log a summary and finalize the evaluation. Creates a summarize call and finishes the evaluate call. @@ -147,16 +137,14 @@ Creates a summarize call and finishes the evaluate call. This method can be called without await (fire-and-forget), but internally it will wait for all pending operations to complete. -#### Parameters +Defined in: [src/evaluationLogger.ts:786](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L786) -| Name | Type | -| :------ | :------ | -| `summary?` | `Record`\<`string`, `any`\> | +#### Parameters -#### Returns +##### summary? -`Promise`\<`void`\> +`Record`\<`string`, `any`\> -#### Defined in +#### Returns -[src/evaluationLogger.ts:786](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L786) \ No newline at end of file +`Promise`\<`void`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/llm.mdx b/weave/reference/typescript-sdk/classes/llm.mdx deleted file mode 100644 index 5e052d71dc..0000000000 --- a/weave/reference/typescript-sdk/classes/llm.mdx +++ /dev/null @@ -1,444 +0,0 @@ ---- -title: "LLM" -description: "TypeScript SDK reference" ---- - -An LLM call. Emits a `chat` span with `gen_ai.*` attributes. - -Created by `weave.startLLM()` (or `turn.startLLM()`) and terminated with -`end()`. Only one LLM may be active in an async context at a time; nest -tool/subagent calls under it via `startTool` / `startSubagent`. - -Populate `inputMessages` / `outputMessages` / `usage` / `reasoning` directly, -or via the helper functions (`output`, `think`, `attachMedia`, `record`). - -All recorded data is flushed to the span at `end()`. - -`Example` - -```ts twoslash -// @noErrors -const llm = weave.startLLM({model: 'gpt-4o-mini', providerName: 'openai'}); - -try { - llm.inputMessages = [{role: 'user', content: prompt}]; - const resp = await openai.chat.completions.create({...}); - llm.output(resp.choices[0].message.content ?? ''); - llm.record({usage: {inputTokens: resp.usage?.prompt_tokens}}); -} finally { - llm.end(); -} -``` - -`Example` - -```ts twoslash -// @noErrors -const llm = weave.startLLM({ - model: 'gpt-4o-mini', - providerName: 'openai', - systemInstructions: ['You are a helpful weather bot.'], - startTime: new Date('2026-05-29T10:00:00.000Z'), -}); - -try { - // ... call the LLM, populate llm.outputMessages / usage ... -} finally { - llm.end(); -} -``` - -## Hierarchy - -- `SpanBase` - - ↳ `LLM` - -## Table of contents - -### Properties - -- [inputMessages](./llm#inputmessages) -- [model](./llm#model) -- [outputMessages](./llm#outputmessages) -- [providerName](./llm#providername) -- [reasoning](./llm#reasoning) -- [usage](./llm#usage) - -### Methods - -- [addEvent](./llm#addevent) -- [attachMedia](./llm#attachmedia) -- [attachMediaUrl](./llm#attachmediaurl) -- [end](./llm#end) -- [output](./llm#output) -- [record](./llm#record) -- [setAttributes](./llm#setattributes) -- [startSubagent](./llm#startsubagent) -- [startTool](./llm#starttool) -- [think](./llm#think) -- [create](./llm#create) - -## Properties - -### inputMessages - -• **inputMessages**: [`Message`](../interfaces/message)[] = `[]` - -Input messages sent to the model. Flushed to `gen_ai.input.messages` on -`end()`. - -#### Defined in - -[src/genai/llm.ts:93](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L93) - -___ - -### model - -• `Readonly` **model**: `string` - -#### Defined in - -[src/genai/llm.ts:117](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L117) - -___ - -### outputMessages - -• **outputMessages**: [`Message`](../interfaces/message)[] = `[]` - -Assistant messages returned by the model. Flushed to -`gen_ai.output.messages` on `end()`. - -#### Defined in - -[src/genai/llm.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L98) - -___ - -### providerName - -• `Readonly` **providerName**: `string` - -#### Defined in - -[src/genai/llm.ts:118](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L118) - -___ - -### reasoning - -• `Optional` **reasoning**: [`Reasoning`](../interfaces/reasoning) - -Chain-of-thought content. Folded into the last assistant message as a -ReasoningPart at serialization time. - -#### Defined in - -[src/genai/llm.ts:105](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L105) - -___ - -### usage - -• **usage**: [`Usage`](../interfaces/usage) = `{}` - -Token counts and cache stats. Flushed to `gen_ai.usage.*` on `end()`. - -#### Defined in - -[src/genai/llm.ts:100](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L100) - -## Methods - -### addEvent - - - **Deprecated.** Record this data via [setAttributes](./llm#setattributes) instead. -OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This -method still works and existing span-event data stays valid. -See https://opentelemetry.io/blog/2026/deprecating-span-events/ - -`Example` - -```ts twoslash -// @noErrors -span.addEvent('context_compacted', {removedMessages: 12}); -``` - - -▸ **addEvent**(`name`, `attributes?`, `startTime?`): `this` - -Add a named event to the span. Useful for marking non-span moments such as -context compaction, tool-loop detection, or guardrail trips. Warns and -no-ops after `end()`. Mirrors OTel `Span.addEvent`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `name` | `string` | -| `attributes?` | `Attributes` | -| `startTime?` | `TimeInput` | - -#### Returns - -`this` - -#### Inherited from - -SpanBase.addEvent - -#### Defined in - -[src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) - -___ - -### attachMedia - -▸ **attachMedia**(`opts`): `this` - -Stage a media attachment for the LLM call. Pick exactly one of - `content` (inline base64 bytes), `uri` (URI reference), or `fileId` - (pre-uploaded file id). The attachment is glued onto the last user - message in `inputMessages` on `end()`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | `AttachMediaOpts` | - -#### Returns - -`this` - -#### Defined in - -[src/genai/llm.ts:183](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L183) - -___ - -### attachMediaUrl - -▸ **attachMediaUrl**(`url`, `opts`): `this` - -Convenience for `attachMedia({uri, modality})`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `url` | `string` | -| `opts` | `Object` | -| `opts.modality` | [`Modality`](../#modality) | - -#### Returns - -`this` - -#### Defined in - -[src/genai/llm.ts:192](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L192) - -___ - -### end - -▸ **end**(`opts?`): `void` - -Flush accumulated state and close the span. Idempotent. Pass `error` to mark failed; pass `endTime` to backdate the close. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | - -#### Returns - -`void` - -#### Defined in - -[src/genai/llm.ts:274](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L274) - -___ - -### output - -▸ **output**(`content`): `this` - -Append an assistant message to the response. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `content` | `string` | - -#### Returns - -`this` - -#### Defined in - -[src/genai/llm.ts:155](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L155) - -___ - -### record - -▸ **record**(`opts`): `this` - -Bulk-set any subset of the mutable fields. Replaces (does not merge). -Useful for assigning everything at once after a provider call returns. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | `Object` | -| `opts.finishReasons?` | `string`[] | -| `opts.inputMessages?` | [`Message`](../interfaces/message)[] | -| `opts.mediaAttachments?` | `AttachMediaOpts`[] | -| `opts.outputMessages?` | [`Message`](../interfaces/message)[] | -| `opts.outputType?` | `string` | -| `opts.reasoning?` | [`Reasoning`](../interfaces/reasoning) | -| `opts.responseId?` | `string` | -| `opts.responseModel?` | `string` | -| `opts.usage?` | [`Usage`](../interfaces/usage) | - -#### Returns - -`this` - -#### Defined in - -[src/genai/llm.ts:203](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L203) - -___ - -### setAttributes - -▸ **setAttributes**(`attributes`): `this` - -Set multiple attributes on the span at once. Warns and no-ops after -`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's -`set_attributes`). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `attributes` | `Attributes` | - -#### Returns - -`this` - -`Example` - -```ts twoslash -// @noErrors -span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); -``` - -#### Inherited from - -SpanBase.setAttributes - -#### Defined in - -[src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) - -___ - -### startSubagent - -▸ **startSubagent**(`opts`): [`SubAgent`](./subagent) - -Start a child SubAgent span nested under this LLM. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`SubAgentInit`](../interfaces/subagentinit) | - -#### Returns - -[`SubAgent`](./subagent) - -#### Defined in - -[src/genai/llm.ts:261](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L261) - -___ - -### startTool - -▸ **startTool**(`opts`): [`Tool`](./tool) - -Start a child Tool span nested under this LLM. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`ToolInit`](../interfaces/toolinit) | - -#### Returns - -[`Tool`](./tool) - -#### Defined in - -[src/genai/llm.ts:252](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L252) - -___ - -### think - -▸ **think**(`content`): `this` - -Set or extend the model's reasoning/chain-of-thought content. Accumulates - into `this.reasoning.content`. Folded into the last assistant message as - a `ReasoningPart` at serialization time, matching the Python SDK's - on-the-wire shape. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `content` | `string` | - -#### Returns - -`this` - -#### Defined in - -[src/genai/llm.ts:167](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L167) - -___ - -### create - -▸ **create**(`opts`): [`LLM`](./llm) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`LLMInit`](../interfaces/llminit) & `ChildSpanContext` | - -#### Returns - -[`LLM`](./llm) - -#### Defined in - -[src/genai/llm.ts:124](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L124) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/messagesprompt.mdx b/weave/reference/typescript-sdk/classes/messagesprompt.mdx index e57c82a2a7..a04ff89cea 100644 --- a/weave/reference/typescript-sdk/classes/messagesprompt.mdx +++ b/weave/reference/typescript-sdk/classes/messagesprompt.mdx @@ -3,173 +3,142 @@ title: "MessagesPrompt" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/prompt.ts:41](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L41) -- `Prompt` - - ↳ `MessagesPrompt` - -## Table of contents - -### Constructors - -- [constructor](./messagesprompt#constructor) - -### Properties - -- [\_\_savedRef](./messagesprompt#__savedref) -- [messages](./messagesprompt#messages) - -### Accessors - -- [description](./messagesprompt#description) -- [name](./messagesprompt#name) +## Extends -### Methods - -- [format](./messagesprompt#format) -- [saveAttrs](./messagesprompt#saveattrs) -- [get](./messagesprompt#get) +- `Prompt` ## Constructors -### constructor +### Constructor + +> **new MessagesPrompt**(`parameters`): `MessagesPrompt` -• **new MessagesPrompt**(`parameters`): [`MessagesPrompt`](./messagesprompt) +Defined in: [src/prompt.ts:44](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L44) #### Parameters -| Name | Type | -| :------ | :------ | -| `parameters` | `MessagesPromptParameters` | +##### parameters + +`MessagesPromptParameters` #### Returns -[`MessagesPrompt`](./messagesprompt) +`MessagesPrompt` #### Overrides -Prompt.constructor - -#### Defined in - -[src/prompt.ts:44](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L44) +`Prompt.constructor` ## Properties ### \_\_savedRef -• `Optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> - -#### Inherited from +> `optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> -Prompt.\_\_savedRef +Defined in: [src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) -#### Defined in +#### Inherited from -[src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) +`Prompt.__savedRef` -___ +*** ### messages -• **messages**: `Record`\<`string`, `any`\>[] +> **messages**: `Record`\<`string`, `any`\>[] -#### Defined in - -[src/prompt.ts:42](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L42) +Defined in: [src/prompt.ts:42](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L42) ## Accessors ### description -• `get` **description**(): `undefined` \| `string` +#### Get Signature -#### Returns +> **get** **description**(): `string` \| `undefined` -`undefined` \| `string` +Defined in: [src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) -#### Inherited from +##### Returns -Prompt.description +`string` \| `undefined` -#### Defined in +#### Inherited from -[src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) +`Prompt.description` -___ +*** ### name -• `get` **name**(): `string` +#### Get Signature -#### Returns +> **get** **name**(): `string` -`string` +Defined in: [src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) -#### Inherited from +##### Returns -Prompt.name +`string` -#### Defined in +#### Inherited from -[src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) +`Prompt.name` ## Methods -### format +### format() -▸ **format**(`values?`): `Record`\<`string`, `any`\>[] +> **format**(`values?`): `Record`\<`string`, `any`\>[] + +Defined in: [src/prompt.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L71) #### Parameters -| Name | Type | -| :------ | :------ | -| `values` | `Record`\<`string`, `any`\> | +##### values? + +`Record`\<`string`, `any`\> = `{}` #### Returns `Record`\<`string`, `any`\>[] -#### Defined in +*** -[src/prompt.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L71) +### saveAttrs() -___ +> **saveAttrs**(): `object` -### saveAttrs - -▸ **saveAttrs**(): `Object` +Defined in: [src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) #### Returns -`Object` +`object` #### Inherited from -Prompt.saveAttrs - -#### Defined in +`Prompt.saveAttrs` -[src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) +*** -___ +### get() -### get +> `static` **get**(`client`, `uri`): `Promise`\<`MessagesPrompt`\> -▸ **get**(`client`, `uri`): `Promise`\<[`MessagesPrompt`](./messagesprompt)\> +Defined in: [src/prompt.ts:77](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L77) #### Parameters -| Name | Type | -| :------ | :------ | -| `client` | [`WeaveClient`](./weaveclient) | -| `uri` | `string` | +##### client -#### Returns +[`WeaveClient`](../interfaces/weaveclient) + +##### uri -`Promise`\<[`MessagesPrompt`](./messagesprompt)\> +`string` -#### Defined in +#### Returns -[src/prompt.ts:77](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L77) \ No newline at end of file +`Promise`\<`MessagesPrompt`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/objectref.mdx b/weave/reference/typescript-sdk/classes/objectref.mdx index 167cd217c8..4c8c81270a 100644 --- a/weave/reference/typescript-sdk/classes/objectref.mdx +++ b/weave/reference/typescript-sdk/classes/objectref.mdx @@ -10,7 +10,9 @@ Generally, end users will not need to interact with this class directly. An ObjectRef contains the project ID, object ID, and digest that uniquely identify a saved object in Weave's storage system. -`Example` +Defined in: [src/weaveObject.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L23) + +## Example ```ts twoslash // @noErrors @@ -18,150 +20,123 @@ const ref = new ObjectRef('my-project', 'abc123', 'def456'); const uri = ref.uri(); // weave:///my-project/object/abc123:def456 ``` -## Table of contents +## Constructors -### Constructors +### Constructor -- [constructor](./objectref#constructor) +> **new ObjectRef**(`projectId`, `objectId`, `digest`): `ObjectRef` -### Properties +Defined in: [src/weaveObject.ts:24](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L24) -- [digest](./objectref#digest) -- [objectId](./objectref#objectid) -- [projectId](./objectref#projectid) +#### Parameters -### Methods +##### projectId -- [get](./objectref#get) -- [ui\_url](./objectref#ui_url) -- [uri](./objectref#uri) -- [fromUri](./objectref#fromuri) +`string` -## Constructors +##### objectId -### constructor +`string` -• **new ObjectRef**(`projectId`, `objectId`, `digest`): [`ObjectRef`](./objectref) +##### digest -#### Parameters - -| Name | Type | -| :------ | :------ | -| `projectId` | `string` | -| `objectId` | `string` | -| `digest` | `string` | +`string` #### Returns -[`ObjectRef`](./objectref) - -#### Defined in - -[src/weaveObject.ts:24](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L24) +`ObjectRef` ## Properties ### digest -• **digest**: `string` - -#### Defined in +> **digest**: `string` -[src/weaveObject.ts:27](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L27) +Defined in: [src/weaveObject.ts:27](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L27) -___ +*** ### objectId -• **objectId**: `string` - -#### Defined in +> **objectId**: `string` -[src/weaveObject.ts:26](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L26) +Defined in: [src/weaveObject.ts:26](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L26) -___ +*** ### projectId -• **projectId**: `string` +> **projectId**: `string` -#### Defined in - -[src/weaveObject.ts:25](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L25) +Defined in: [src/weaveObject.ts:25](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L25) ## Methods -### get +### get() + +> **get**(): `Promise`\<`any`\> -▸ **get**(): `Promise`\<`any`\> +Defined in: [src/weaveObject.ts:64](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L64) #### Returns `Promise`\<`any`\> -#### Defined in +*** -[src/weaveObject.ts:64](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L64) +### ui\_url() -___ +> **ui\_url**(): `string` -### ui\_url - -▸ **ui_url**(): `string` +Defined in: [src/weaveObject.ts:59](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L59) #### Returns `string` -#### Defined in - -[src/weaveObject.ts:59](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L59) +*** -___ +### uri() -### uri +> **uri**(): `string` -▸ **uri**(): `string` +Defined in: [src/weaveObject.ts:55](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L55) #### Returns `string` -#### Defined in +*** -[src/weaveObject.ts:55](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L55) +### fromUri() -___ - -### fromUri - -▸ **fromUri**(`uri`): [`ObjectRef`](./objectref) +> `static` **fromUri**(`uri`): `ObjectRef` Creates an ObjectRef from a Weave URI string. +Defined in: [src/weaveObject.ts:42](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L42) + #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `uri` | `string` | A Weave URI in the format: weave:///entity/project/object/name:digest | +##### uri + +`string` + +A Weave URI in the format: weave:///entity/project/object/name:digest #### Returns -[`ObjectRef`](./objectref) +`ObjectRef` A new ObjectRef instance -`Throws` +#### Throws Error if the URI format is invalid or not an object ref -`Example` +#### Example ```ts twoslash // @noErrors const ref = ObjectRef.fromUri('weave:///my-entity/my-project/object/my-dataset:abc123'); -``` - -#### Defined in - -[src/weaveObject.ts:42](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L42) \ No newline at end of file +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/scorelogger.mdx b/weave/reference/typescript-sdk/classes/scorelogger.mdx index 154d62faec..5f374b7860 100644 --- a/weave/reference/typescript-sdk/classes/scorelogger.mdx +++ b/weave/reference/typescript-sdk/classes/scorelogger.mdx @@ -6,7 +6,9 @@ description: "TypeScript SDK reference" ScoreLogger manages scoring for a single prediction. Returned from EvaluationLogger.logPrediction(). -`Example` +Defined in: [src/evaluationLogger.ts:330](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L330) + +## Example ```ts twoslash // @noErrors @@ -16,96 +18,82 @@ await pred.logScore("relevance", 0.8); await pred.finish(); // Finalizes the prediction ``` -## Table of contents - -### Constructors - -- [constructor](./scorelogger#constructor) - -### Accessors - -- [isFinishCalled](./scorelogger#isfinishcalled) - -### Methods - -- [finish](./scorelogger#finish) -- [logScore](./scorelogger#logscore) - ## Constructors -### constructor +### Constructor -• **new ScoreLogger**(`evalLogger`): [`ScoreLogger`](./scorelogger) +> **new ScoreLogger**(`evalLogger`): `ScoreLogger` -#### Parameters +Defined in: [src/evaluationLogger.ts:338](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L338) -| Name | Type | -| :------ | :------ | -| `evalLogger` | [`EvaluationLogger`](./evaluationlogger) | +#### Parameters -#### Returns +##### evalLogger -[`ScoreLogger`](./scorelogger) +[`EvaluationLogger`](./evaluationlogger) -#### Defined in +#### Returns -[src/evaluationLogger.ts:338](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L338) +`ScoreLogger` ## Accessors ### isFinishCalled -• `get` **isFinishCalled**(): `boolean` +#### Get Signature + +> **get** **isFinishCalled**(): `boolean` Check if finish() has been called. Used by EvaluationLogger to detect unfinished predictions. -#### Returns +Defined in: [src/evaluationLogger.ts:368](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L368) -`boolean` - -#### Defined in +##### Returns -[src/evaluationLogger.ts:368](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L368) +`boolean` ## Methods -### finish +### finish() -▸ **finish**(): `Promise`\<`void`\> +> **finish**(): `Promise`\<`void`\> Finish the scoring process for the prediction. Finalizes the predict_and_score call with accumulated scores. Updates incremental aggregates and frees memory. +Defined in: [src/evaluationLogger.ts:470](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L470) + #### Returns `Promise`\<`void`\> -#### Defined in +*** -[src/evaluationLogger.ts:470](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L470) +### logScore() -___ - -### logScore - -▸ **logScore**(`scorerName`, `score`): `Promise`\<`void`\> +> **logScore**(`scorerName`, `score`): `Promise`\<`void`\> Log a score for this prediction. Creates a scorer call as a child of predict_and_score. +Defined in: [src/evaluationLogger.ts:379](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L379) + #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `scorerName` | `string` | Name of the scorer (e.g., "accuracy", "f1_score") | -| `score` | `any` | The score value | +##### scorerName -#### Returns +`string` -`Promise`\<`void`\> +Name of the scorer (e.g., "accuracy", "f1_score") + +##### score -#### Defined in +`any` + +The score value + +#### Returns -[src/evaluationLogger.ts:379](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/evaluationLogger.ts#L379) \ No newline at end of file +`Promise`\<`void`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/stringprompt.mdx b/weave/reference/typescript-sdk/classes/stringprompt.mdx index bdf1aecea9..811d91e0ad 100644 --- a/weave/reference/typescript-sdk/classes/stringprompt.mdx +++ b/weave/reference/typescript-sdk/classes/stringprompt.mdx @@ -3,173 +3,142 @@ title: "StringPrompt" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/prompt.ts:18](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L18) -- `Prompt` - - ↳ `StringPrompt` - -## Table of contents - -### Constructors - -- [constructor](./stringprompt#constructor) - -### Properties - -- [\_\_savedRef](./stringprompt#__savedref) -- [content](./stringprompt#content) - -### Accessors - -- [description](./stringprompt#description) -- [name](./stringprompt#name) +## Extends -### Methods - -- [format](./stringprompt#format) -- [saveAttrs](./stringprompt#saveattrs) -- [get](./stringprompt#get) +- `Prompt` ## Constructors -### constructor +### Constructor + +> **new StringPrompt**(`parameters`): `StringPrompt` -• **new StringPrompt**(`parameters`): [`StringPrompt`](./stringprompt) +Defined in: [src/prompt.ts:21](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L21) #### Parameters -| Name | Type | -| :------ | :------ | -| `parameters` | `StringPromptParameters` | +##### parameters + +`StringPromptParameters` #### Returns -[`StringPrompt`](./stringprompt) +`StringPrompt` #### Overrides -Prompt.constructor - -#### Defined in - -[src/prompt.ts:21](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L21) +`Prompt.constructor` ## Properties ### \_\_savedRef -• `Optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> - -#### Inherited from +> `optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> -Prompt.\_\_savedRef +Defined in: [src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) -#### Defined in +#### Inherited from -[src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) +`Prompt.__savedRef` -___ +*** ### content -• **content**: `string` +> **content**: `string` -#### Defined in - -[src/prompt.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L19) +Defined in: [src/prompt.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L19) ## Accessors ### description -• `get` **description**(): `undefined` \| `string` +#### Get Signature -#### Returns +> **get** **description**(): `string` \| `undefined` -`undefined` \| `string` +Defined in: [src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) -#### Inherited from +##### Returns -Prompt.description +`string` \| `undefined` -#### Defined in +#### Inherited from -[src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) +`Prompt.description` -___ +*** ### name -• `get` **name**(): `string` +#### Get Signature -#### Returns +> **get** **name**(): `string` -`string` +Defined in: [src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) -#### Inherited from +##### Returns -Prompt.name +`string` -#### Defined in +#### Inherited from -[src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) +`Prompt.name` ## Methods -### format +### format() -▸ **format**(`values?`): `string` +> **format**(`values?`): `string` + +Defined in: [src/prompt.ts:26](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L26) #### Parameters -| Name | Type | -| :------ | :------ | -| `values` | `Record`\<`string`, `any`\> | +##### values? + +`Record`\<`string`, `any`\> = `{}` #### Returns `string` -#### Defined in +*** -[src/prompt.ts:26](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L26) +### saveAttrs() -___ +> **saveAttrs**(): `object` -### saveAttrs - -▸ **saveAttrs**(): `Object` +Defined in: [src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) #### Returns -`Object` +`object` #### Inherited from -Prompt.saveAttrs - -#### Defined in +`Prompt.saveAttrs` -[src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) +*** -___ +### get() -### get +> `static` **get**(`client`, `uri`): `Promise`\<`StringPrompt`\> -▸ **get**(`client`, `uri`): `Promise`\<[`StringPrompt`](./stringprompt)\> +Defined in: [src/prompt.ts:30](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L30) #### Parameters -| Name | Type | -| :------ | :------ | -| `client` | [`WeaveClient`](./weaveclient) | -| `uri` | `string` | +##### client -#### Returns +[`WeaveClient`](../interfaces/weaveclient) + +##### uri -`Promise`\<[`StringPrompt`](./stringprompt)\> +`string` -#### Defined in +#### Returns -[src/prompt.ts:30](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/prompt.ts#L30) \ No newline at end of file +`Promise`\<`StringPrompt`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/subagent.mdx b/weave/reference/typescript-sdk/classes/subagent.mdx deleted file mode 100644 index 6b1f10eb1c..0000000000 --- a/weave/reference/typescript-sdk/classes/subagent.mdx +++ /dev/null @@ -1,204 +0,0 @@ ---- -title: "SubAgent" -description: "TypeScript SDK reference" ---- - -## Hierarchy - -- `SpanBase` - - ↳ `SubAgent` - -## Table of contents - -### Accessors - -- [model](./subagent#model) -- [name](./subagent#name) - -### Methods - -- [addEvent](./subagent#addevent) -- [end](./subagent#end) -- [record](./subagent#record) -- [setAttributes](./subagent#setattributes) -- [create](./subagent#create) - -## Accessors - -### model - -• `get` **model**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/subagent.ts:78](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L78) - -___ - -### name - -• `get` **name**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/subagent.ts:74](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L74) - -## Methods - -### addEvent - - - **Deprecated.** Record this data via [setAttributes](./subagent#setattributes) instead. -OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This -method still works and existing span-event data stays valid. -See https://opentelemetry.io/blog/2026/deprecating-span-events/ - -`Example` - -```ts twoslash -// @noErrors -span.addEvent('context_compacted', {removedMessages: 12}); -``` - - -▸ **addEvent**(`name`, `attributes?`, `startTime?`): `this` - -Add a named event to the span. Useful for marking non-span moments such as -context compaction, tool-loop detection, or guardrail trips. Warns and -no-ops after `end()`. Mirrors OTel `Span.addEvent`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `name` | `string` | -| `attributes?` | `Attributes` | -| `startTime?` | `TimeInput` | - -#### Returns - -`this` - -#### Inherited from - -SpanBase.addEvent - -#### Defined in - -[src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) - -___ - -### end - -▸ **end**(`opts?`): `void` - -Read current field values (to reflect mutations made via `record()` -since `start`) and close the span. Idempotent. Pass `error` to mark -it as failed; pass `endTime` to backdate the close. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | - -#### Returns - -`void` - -#### Defined in - -[src/genai/subagent.ts:153](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L153) - -___ - -### record - -▸ **record**(`opts`): `this` - -Bulk-set any fields. Replaces (does not merge). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | `Object` | -| `opts.agentDescription?` | `string` | -| `opts.agentId?` | `string` | -| `opts.agentVersion?` | `string` | -| `opts.model?` | `string` | -| `opts.name?` | `string` | -| `opts.systemInstructions?` | `string`[] | - -#### Returns - -`this` - -#### Defined in - -[src/genai/subagent.ts:117](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L117) - -___ - -### setAttributes - -▸ **setAttributes**(`attributes`): `this` - -Set multiple attributes on the span at once. Warns and no-ops after -`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's -`set_attributes`). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `attributes` | `Attributes` | - -#### Returns - -`this` - -`Example` - -```ts twoslash -// @noErrors -span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); -``` - -#### Inherited from - -SpanBase.setAttributes - -#### Defined in - -[src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) - -___ - -### create - -▸ **create**(`opts`): [`SubAgent`](./subagent) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`SubAgentInit`](../interfaces/subagentinit) & `ChildSpanContext` | - -#### Returns - -[`SubAgent`](./subagent) - -#### Defined in - -[src/genai/subagent.ts:93](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L93) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/tool.mdx b/weave/reference/typescript-sdk/classes/tool.mdx deleted file mode 100644 index 8b556c5996..0000000000 --- a/weave/reference/typescript-sdk/classes/tool.mdx +++ /dev/null @@ -1,213 +0,0 @@ ---- -title: "Tool" -description: "TypeScript SDK reference" ---- - -A tool invocation. Emits an `execute_tool` span carrying the tool name, -the JSON-encoded arguments, the tool-call id, and the result. - -Created by `weave.startTool()` (or `turn.startTool()`, or -`llm.startTool()`) and terminated with `end()`. Assign `result` before -calling `end()` to record the tool's output on the span. - -`Example` - -```ts twoslash -// @noErrors -const tool = weave.startTool({ - name: tc.function.name, - args: tc.function.arguments, - toolCallId: tc.id, -}); -try { - tool.result = await wikipediaSearch(JSON.parse(tc.function.arguments)); -} finally { - tool.end(); -} -``` - -## Hierarchy - -- `SpanBase` - - ↳ `Tool` - -## Table of contents - -### Properties - -- [args](./tool#args) -- [name](./tool#name) -- [result](./tool#result) -- [toolCallId](./tool#toolcallid) - -### Methods - -- [addEvent](./tool#addevent) -- [end](./tool#end) -- [setAttributes](./tool#setattributes) -- [create](./tool#create) - -## Properties - -### args - -• `Readonly` **args**: `string` - -#### Defined in - -[src/genai/tool.ts:52](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L52) - -___ - -### name - -• `Readonly` **name**: `string` - -#### Defined in - -[src/genai/tool.ts:51](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L51) - -___ - -### result - -• `Optional` **result**: `string` - -Tool output as a string. Recorded on `gen_ai.tool.call.result` at `end()`. - -#### Defined in - -[src/genai/tool.ts:47](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L47) - -___ - -### toolCallId - -• `Readonly` **toolCallId**: `string` - -#### Defined in - -[src/genai/tool.ts:53](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L53) - -## Methods - -### addEvent - - - **Deprecated.** Record this data via [setAttributes](./tool#setattributes) instead. -OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This -method still works and existing span-event data stays valid. -See https://opentelemetry.io/blog/2026/deprecating-span-events/ - -`Example` - -```ts twoslash -// @noErrors -span.addEvent('context_compacted', {removedMessages: 12}); -``` - - -▸ **addEvent**(`name`, `attributes?`, `startTime?`): `this` - -Add a named event to the span. Useful for marking non-span moments such as -context compaction, tool-loop detection, or guardrail trips. Warns and -no-ops after `end()`. Mirrors OTel `Span.addEvent`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `name` | `string` | -| `attributes?` | `Attributes` | -| `startTime?` | `TimeInput` | - -#### Returns - -`this` - -#### Inherited from - -SpanBase.addEvent - -#### Defined in - -[src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) - -___ - -### end - -▸ **end**(`opts?`): `void` - -Flush `result` to the span and close it. Idempotent. Pass `error` to mark -the span as failed; pass `endTime` to backdate the close. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | - -#### Returns - -`void` - -#### Defined in - -[src/genai/tool.ts:87](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L87) - -___ - -### setAttributes - -▸ **setAttributes**(`attributes`): `this` - -Set multiple attributes on the span at once. Warns and no-ops after -`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's -`set_attributes`). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `attributes` | `Attributes` | - -#### Returns - -`this` - -`Example` - -```ts twoslash -// @noErrors -span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); -``` - -#### Inherited from - -SpanBase.setAttributes - -#### Defined in - -[src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) - -___ - -### create - -▸ **create**(`opts`): [`Tool`](./tool) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`ToolInit`](../interfaces/toolinit) & `ChildSpanContext` | - -#### Returns - -[`Tool`](./tool) - -#### Defined in - -[src/genai/tool.ts:58](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L58) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/turn.mdx b/weave/reference/typescript-sdk/classes/turn.mdx deleted file mode 100644 index dbe66c7d95..0000000000 --- a/weave/reference/typescript-sdk/classes/turn.mdx +++ /dev/null @@ -1,304 +0,0 @@ ---- -title: "Turn" -description: "TypeScript SDK reference" ---- - -## Hierarchy - -- `SpanBase` - - ↳ `Turn` - -## Table of contents - -### Accessors - -- [agentName](./turn#agentname) -- [model](./turn#model) - -### Methods - -- [addEvent](./turn#addevent) -- [end](./turn#end) -- [record](./turn#record) -- [setAttribute](./turn#setattribute) -- [setAttributes](./turn#setattributes) -- [startLLM](./turn#startllm) -- [startSubagent](./turn#startsubagent) -- [startTool](./turn#starttool) -- [create](./turn#create) - -## Accessors - -### agentName - -• `get` **agentName**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/turn.ts:103](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L103) - -___ - -### model - -• `get` **model**(): `string` - -#### Returns - -`string` - -#### Defined in - -[src/genai/turn.ts:107](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L107) - -## Methods - -### addEvent - - - **Deprecated.** Record this data via [setAttributes](./turn#setattributes) instead. -OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This -method still works and existing span-event data stays valid. -See https://opentelemetry.io/blog/2026/deprecating-span-events/ - -`Example` - -```ts twoslash -// @noErrors -span.addEvent('context_compacted', {removedMessages: 12}); -``` - - -▸ **addEvent**(`name`, `attributes?`, `startTime?`): `this` - -Add a named event to the span. Useful for marking non-span moments such as -context compaction, tool-loop detection, or guardrail trips. Warns and -no-ops after `end()`. Mirrors OTel `Span.addEvent`. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `name` | `string` | -| `attributes?` | `Attributes` | -| `startTime?` | `TimeInput` | - -#### Returns - -`this` - -#### Inherited from - -SpanBase.addEvent - -#### Defined in - -[src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) - -___ - -### end - -▸ **end**(`opts?`): `void` - -Read current field values (to reflect mutations made via `record()` -since `start`) and close the span. Idempotent. Pass `error` to mark -it as failed; pass `endTime` to backdate the close. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | - -#### Returns - -`void` - -#### Defined in - -[src/genai/turn.ts:241](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L241) - -___ - -### record - -▸ **record**(`opts`): `this` - -Bulk-set any subset of the mutable fields. Replaces (does not merge). -Useful for assigning everything at once after a provider call returns. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | `Object` | -| `opts.agentDescription?` | `string` | -| `opts.agentId?` | `string` | -| `opts.agentName?` | `string` | -| `opts.agentVersion?` | `string` | -| `opts.messages?` | [`Message`](../interfaces/message)[] | -| `opts.model?` | `string` | -| `opts.systemInstructions?` | `string`[] | - -#### Returns - -`this` - -#### Defined in - -[src/genai/turn.ts:201](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L201) - -___ - -### setAttribute - - - **Deprecated.** Use [setAttributes](./turn#setattributes) instead, which mirrors the Python -SDK's `set_attributes` and OTel's `Span.setAttributes`. Retained as a thin -alias so existing single-attribute callers keep working. Only `Turn` -carries this — the other emitters never shipped a singular form. - - -▸ **setAttribute**(`key`, `value`): `this` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `key` | `string` | -| `value` | `AttributeValue` | - -#### Returns - -`this` - -#### Defined in - -[src/genai/turn.ts:193](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L193) - -___ - -### setAttributes - -▸ **setAttributes**(`attributes`): `this` - -Set multiple attributes on the span at once. Warns and no-ops after -`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's -`set_attributes`). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `attributes` | `Attributes` | - -#### Returns - -`this` - -`Example` - -```ts twoslash -// @noErrors -span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); -``` - -#### Inherited from - -SpanBase.setAttributes - -#### Defined in - -[src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) - -___ - -### startLLM - -▸ **startLLM**(`opts`): [`LLM`](./llm) - -Start a child LLM span under this Turn. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`LLMInit`](../interfaces/llminit) | - -#### Returns - -[`LLM`](./llm) - -#### Defined in - -[src/genai/turn.ts:161](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L161) - -___ - -### startSubagent - -▸ **startSubagent**(`opts`): [`SubAgent`](./subagent) - -Start a child SubAgent span under this Turn. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`SubAgentInit`](../interfaces/subagentinit) | - -#### Returns - -[`SubAgent`](./subagent) - -#### Defined in - -[src/genai/turn.ts:179](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L179) - -___ - -### startTool - -▸ **startTool**(`opts`): [`Tool`](./tool) - -Start a child Tool span under this Turn. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`ToolInit`](../interfaces/toolinit) | - -#### Returns - -[`Tool`](./tool) - -#### Defined in - -[src/genai/turn.ts:170](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L170) - -___ - -### create - -▸ **create**(`opts?`): [`Turn`](./turn) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`TurnInit`](../interfaces/turninit) & \{ `conversationId?`: `string` } | - -#### Returns - -[`Turn`](./turn) - -#### Defined in - -[src/genai/turn.ts:124](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L124) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/weaveadkplugin.mdx b/weave/reference/typescript-sdk/classes/weaveadkplugin.mdx index 46f0303fbb..329c031f59 100644 --- a/weave/reference/typescript-sdk/classes/weaveadkplugin.mdx +++ b/weave/reference/typescript-sdk/classes/weaveadkplugin.mdx @@ -11,100 +11,93 @@ invokes every callback, so all are present even where a callback is a no-op. ADK treats any non-`undefined` return as a short-circuit, so every callback swallows its own errors and returns `undefined`. +Defined in: [src/integrations/googleAdk.ts:589](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L589) + ## Implements - `BasePlugin` -## Table of contents +## Constructors -### Constructors +### Constructor -- [constructor](./weaveadkplugin#constructor) +> **new WeaveAdkPlugin**(): `WeaveAdkPlugin` -### Properties +#### Returns -- [name](./weaveadkplugin#name) +`WeaveAdkPlugin` -### Methods +## Properties -- [afterAgentCallback](./weaveadkplugin#afteragentcallback) -- [afterContextCompaction](./weaveadkplugin#aftercontextcompaction) -- [afterModelCallback](./weaveadkplugin#aftermodelcallback) -- [afterRunCallback](./weaveadkplugin#afterruncallback) -- [afterToolCallback](./weaveadkplugin#aftertoolcallback) -- [beforeAgentCallback](./weaveadkplugin#beforeagentcallback) -- [beforeContextCompaction](./weaveadkplugin#beforecontextcompaction) -- [beforeModelCallback](./weaveadkplugin#beforemodelcallback) -- [beforeRunCallback](./weaveadkplugin#beforeruncallback) -- [beforeToolCallback](./weaveadkplugin#beforetoolcallback) -- [beforeToolSelection](./weaveadkplugin#beforetoolselection) -- [finishInterruptedInvocation](./weaveadkplugin#finishinterruptedinvocation) -- [onEventCallback](./weaveadkplugin#oneventcallback) -- [onModelErrorCallback](./weaveadkplugin#onmodelerrorcallback) -- [onToolErrorCallback](./weaveadkplugin#ontoolerrorcallback) -- [onUserMessageCallback](./weaveadkplugin#onusermessagecallback) +### name -## Constructors +> `readonly` **name**: `"weave"` = `WEAVE_ADK_PLUGIN_NAME` -### constructor +Defined in: [src/integrations/googleAdk.ts:590](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L590) -• **new WeaveAdkPlugin**(): [`WeaveAdkPlugin`](./weaveadkplugin) +#### Implementation of -#### Returns +`AdkBasePlugin.name` -[`WeaveAdkPlugin`](./weaveadkplugin) +## Methods -## Properties +### afterAgentCallback() -### name +> **afterAgentCallback**(`params`): `Promise`\<`undefined`\> -• `Readonly` **name**: ``"weave"`` +Callback executed after an agent's primary logic has completed. -#### Implementation of +This callback can be used to inspect, log, or modify the agent's final +result before it is returned. + +Defined in: [src/integrations/googleAdk.ts:779](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L779) -AdkBasePlugin.name +#### Parameters -#### Defined in +##### params -[src/integrations/googleAdk.ts:590](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L590) +###### agent -## Methods +`BaseAgent` -### afterAgentCallback +The agent that has just run. -▸ **afterAgentCallback**(`params`): `Promise`\<`undefined`\> +###### callbackContext -#### Parameters +`Context` -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.agent` | `BaseAgent` | -| `params.callbackContext` | `Context` | +The context for the agent invocation. #### Returns `Promise`\<`undefined`\> +An optional `Content` object. If a value is returned, it will + replace the agent's original result. Returning `undefined` uses the + original, unmodified result. + #### Implementation of -AdkBasePlugin.afterAgentCallback +`AdkBasePlugin.afterAgentCallback` -#### Defined in +*** -[src/integrations/googleAdk.ts:779](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L779) +### afterContextCompaction() -___ +> **afterContextCompaction**(`_params`): `Promise`\<`undefined`\> -### afterContextCompaction +Callback executed after context compaction. -▸ **afterContextCompaction**(`_params`): `Promise`\<`undefined`\> +This callback provides an opportunity to inspect the context +after it has been compacted. + +Defined in: [src/integrations/googleAdk.ts:997](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L997) #### Parameters -| Name | Type | -| :------ | :------ | -| `_params` | `unknown` | +##### \_params + +`unknown` #### Returns @@ -112,128 +105,195 @@ ___ #### Implementation of -AdkBasePlugin.afterContextCompaction +`AdkBasePlugin.afterContextCompaction` -#### Defined in +*** -[src/integrations/googleAdk.ts:997](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L997) +### afterModelCallback() -___ +> **afterModelCallback**(`params`): `Promise`\<`undefined`\> -### afterModelCallback +Callback executed after a response is received from the model. -▸ **afterModelCallback**(`params`): `Promise`\<`undefined`\> +This is the ideal place to log model responses, collect metrics on token +usage, or perform post-processing on the raw `LlmResponse`. + +Defined in: [src/integrations/googleAdk.ts:841](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L841) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.callbackContext` | `Context` | -| `params.llmResponse` | `LlmResponse` | +##### params + +###### callbackContext + +`Context` + +The context for the current agent call. + +###### llmResponse + +`LlmResponse` + +The response object received from the model. #### Returns `Promise`\<`undefined`\> +An optional value. A non-`undefined` return may be used by the + framework to modify or replace the response. Returning `undefined` + allows the original response to be used. + #### Implementation of -AdkBasePlugin.afterModelCallback +`AdkBasePlugin.afterModelCallback` -#### Defined in +*** -[src/integrations/googleAdk.ts:841](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L841) +### afterRunCallback() -___ +> **afterRunCallback**(`params`): `Promise`\<`undefined`\> -### afterRunCallback +Callback executed after an ADK runner run has completed. -▸ **afterRunCallback**(`params`): `Promise`\<`undefined`\> +This is the final callback in the ADK lifecycle, suitable for cleanup, +final logging, or reporting tasks. + +Defined in: [src/integrations/googleAdk.ts:713](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L713) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.invocationContext` | `InvocationContext` | +##### params + +###### invocationContext + +`InvocationContext` + +The context for the entire invocation. #### Returns `Promise`\<`undefined`\> +undefined + #### Implementation of -AdkBasePlugin.afterRunCallback +`AdkBasePlugin.afterRunCallback` + +*** -#### Defined in +### afterToolCallback() -[src/integrations/googleAdk.ts:713](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L713) +> **afterToolCallback**(`params`): `Promise`\<`undefined`\> -___ +Callback executed after a tool has been called. -### afterToolCallback +This callback allows for inspecting, logging, or modifying the result +returned by a tool. -▸ **afterToolCallback**(`params`): `Promise`\<`undefined`\> +Defined in: [src/integrations/googleAdk.ts:965](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L965) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.result` | ``null`` \| `Record`\<`string`, `unknown`\> | -| `params.tool` | `BaseTool` | -| `params.toolArgs` | `Record`\<`string`, `unknown`\> | -| `params.toolContext` | `Context` | +##### params + +###### result + +`Record`\<`string`, `unknown`\> \| `null` + +The dictionary returned by the tool invocation. + +###### tool + +`BaseTool` + +The tool instance that has just been executed. + +###### toolArgs + +`Record`\<`string`, `unknown`\> + +The original arguments that were passed to the tool. + +###### toolContext + +`Context` + +The context specific to the tool execution. #### Returns `Promise`\<`undefined`\> +An optional dictionary. If a dictionary is returned, it will + **replace** the original result from the tool. This allows for + post-processing or altering tool outputs. Returning `undefined` uses + the original, unmodified result. + #### Implementation of -AdkBasePlugin.afterToolCallback +`AdkBasePlugin.afterToolCallback` + +*** -#### Defined in +### beforeAgentCallback() -[src/integrations/googleAdk.ts:965](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L965) +> **beforeAgentCallback**(`params`): `Promise`\<`undefined`\> -___ +Callback executed before an agent's primary logic is invoked. -### beforeAgentCallback +This callback can be used for logging, setup, or to short-circuit the +agent's execution by returning a value. -▸ **beforeAgentCallback**(`params`): `Promise`\<`undefined`\> +Defined in: [src/integrations/googleAdk.ts:765](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L765) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.agent` | `BaseAgent` | -| `params.callbackContext` | `Context` | +##### params + +###### agent + +`BaseAgent` + +The agent that is about to run. + +###### callbackContext + +`Context` + +The context for the agent invocation. #### Returns `Promise`\<`undefined`\> +An optional `Content` object. If a value is returned, it will + bypass the agent's callbacks and its execution, and return this value + directly. Returning `undefined` allows the agent to proceed normally. + #### Implementation of -AdkBasePlugin.beforeAgentCallback +`AdkBasePlugin.beforeAgentCallback` + +*** -#### Defined in +### beforeContextCompaction() -[src/integrations/googleAdk.ts:765](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L765) +> **beforeContextCompaction**(`_params`): `Promise`\<`undefined`\> -___ +Callback executed before context compaction. -### beforeContextCompaction +This callback provides an opportunity to inspect or modify the context +before it is compacted. -▸ **beforeContextCompaction**(`_params`): `Promise`\<`undefined`\> +Defined in: [src/integrations/googleAdk.ts:993](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L993) #### Parameters -| Name | Type | -| :------ | :------ | -| `_params` | `unknown` | +##### \_params + +`unknown` #### Returns @@ -241,119 +301,170 @@ ___ #### Implementation of -AdkBasePlugin.beforeContextCompaction +`AdkBasePlugin.beforeContextCompaction` + +*** -#### Defined in +### beforeModelCallback() -[src/integrations/googleAdk.ts:993](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L993) +> **beforeModelCallback**(`params`): `Promise`\<`undefined`\> -___ +Callback executed before a request is sent to the model. -### beforeModelCallback +This provides an opportunity to inspect, log, or modify the `LlmRequest` +object. It can also be used to implement caching by returning a cached +`LlmResponse`, which would skip the actual model call. -▸ **beforeModelCallback**(`params`): `Promise`\<`undefined`\> +Defined in: [src/integrations/googleAdk.ts:804](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L804) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.callbackContext` | `Context` | -| `params.llmRequest` | `LlmRequest` | +##### params + +###### callbackContext + +`Context` + +The context for the current agent call. + +###### llmRequest + +`LlmRequest` + +The prepared request object to be sent to the model. #### Returns `Promise`\<`undefined`\> +An optional value. The interpretation of a non-`undefined` + trigger an early exit and returns the response immediately. Returning + `undefined` allows the LLM request to proceed normally. + #### Implementation of -AdkBasePlugin.beforeModelCallback +`AdkBasePlugin.beforeModelCallback` + +*** -#### Defined in +### beforeRunCallback() -[src/integrations/googleAdk.ts:804](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L804) +> **beforeRunCallback**(`params`): `Promise`\<`undefined`\> -___ +Callback executed before the ADK runner runs. -### beforeRunCallback +This is the first callback to be called in the lifecycle, ideal for global +setup or initialization tasks. -▸ **beforeRunCallback**(`params`): `Promise`\<`undefined`\> +Defined in: [src/integrations/googleAdk.ts:621](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L621) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.invocationContext` | `InvocationContext` | +##### params + +###### invocationContext + +`InvocationContext` + +The context for the entire invocation, containing + session information, the root agent, etc. #### Returns `Promise`\<`undefined`\> +An optional `Event` to be returned to the ADK. Returning a value + to halt execution of the runner and ends the runner with that event. + Return `undefined` to proceed normally. + #### Implementation of -AdkBasePlugin.beforeRunCallback +`AdkBasePlugin.beforeRunCallback` -#### Defined in +*** -[src/integrations/googleAdk.ts:621](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L621) +### beforeToolCallback() -___ +> **beforeToolCallback**(`params`): `Promise`\<`undefined`\> -### beforeToolCallback +Callback executed before a tool is called. -▸ **beforeToolCallback**(`params`): `Promise`\<`undefined`\> +This callback is useful for logging tool usage, input validation, or +modifying the arguments before they are passed to the tool. + +Defined in: [src/integrations/googleAdk.ts:918](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L918) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.tool` | `BaseTool` | -| `params.toolArgs` | `Record`\<`string`, `unknown`\> | -| `params.toolContext` | `Context` | +##### params + +###### tool + +`BaseTool` + +The tool instance that is about to be executed. + +###### toolArgs + +`Record`\<`string`, `unknown`\> + +The dictionary of arguments to be used for invoking the + tool. + +###### toolContext + +`Context` + +The context specific to the tool execution. #### Returns `Promise`\<`undefined`\> +An optional dictionary. If a dictionary is returned, it will stop + the tool execution and return this response immediately. Returning + `undefined` uses the original, unmodified arguments. + #### Implementation of -AdkBasePlugin.beforeToolCallback +`AdkBasePlugin.beforeToolCallback` + +*** -#### Defined in +### beforeToolSelection() -[src/integrations/googleAdk.ts:918](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L918) +> **beforeToolSelection**(`_params`): `Promise`\<`undefined`\> -___ +Callback executed before a tool is selected. -### beforeToolSelection +This callback provides an opportunity to inspect, log, or modify the +available tools before they are selected. -▸ **beforeToolSelection**(`_params`): `Promise`\<`undefined`\> +Defined in: [src/integrations/googleAdk.ts:914](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L914) #### Parameters -| Name | Type | -| :------ | :------ | -| `_params` | `unknown` | +##### \_params + +`unknown` #### Returns `Promise`\<`undefined`\> -#### Implementation of - -AdkBasePlugin.beforeToolSelection +An optional value. A non-`undefined` return may be used by the + framework to modify or replace the available tools. Returning + `undefined` allows the original tools to be used. -#### Defined in +#### Implementation of -[src/integrations/googleAdk.ts:914](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L914) +`AdkBasePlugin.beforeToolSelection` -___ +*** -### finishInterruptedInvocation +### finishInterruptedInvocation() -▸ **finishInterruptedInvocation**(`invocationId`): `void` +> **finishInterruptedInvocation**(`invocationId`): `void` Finalizes a run that never reached `afterRunCallback`. ADK only dispatches `afterRunCallback` after the event loop drains normally, so a consumer that @@ -362,123 +473,206 @@ breaks out of `runAsync` early — or an aborted run — leaves the invocation `finally` to close them as interrupted. Idempotent: a no-op once the run has already finished (the common, fully-consumed case). +Defined in: [src/integrations/googleAdk.ts:732](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L732) + #### Parameters -| Name | Type | -| :------ | :------ | -| `invocationId` | `string` | +##### invocationId + +`string` #### Returns `void` -#### Defined in +*** -[src/integrations/googleAdk.ts:732](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L732) +### onEventCallback() -___ +> **onEventCallback**(`params`): `Promise`\<`undefined`\> -### onEventCallback +Callback executed after an event is yielded from runner. -▸ **onEventCallback**(`params`): `Promise`\<`undefined`\> +This is the ideal place to make modification to the event before the event +is handled by the underlying agent app. + +Defined in: [src/integrations/googleAdk.ts:693](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L693) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.event` | `Event` | -| `params.invocationContext` | `InvocationContext` | +##### params + +###### event + +`Event` + +The event raised by the runner. + +###### invocationContext + +`InvocationContext` + +The context for the entire invocation. #### Returns `Promise`\<`undefined`\> +An optional value. A non-`undefined` return may be used by the + framework to modify or replace the response. Copy `params.event` when + constructing a replacement to preserve fields that are not being + modified, such as event actions. Returning `undefined` allows the + original response to be used. + #### Implementation of -AdkBasePlugin.onEventCallback +`AdkBasePlugin.onEventCallback` -#### Defined in +*** -[src/integrations/googleAdk.ts:693](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L693) +### onModelErrorCallback() -___ +> **onModelErrorCallback**(`params`): `Promise`\<`undefined`\> -### onModelErrorCallback +Callback executed when a model call encounters an error. -▸ **onModelErrorCallback**(`params`): `Promise`\<`undefined`\> +This callback provides an opportunity to handle model errors gracefully, +potentially providing alternative responses or recovery mechanisms. + +Defined in: [src/integrations/googleAdk.ts:884](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L884) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.callbackContext` | `Context` | -| `params.error` | `Error` | -| `params.llmRequest` | `LlmRequest` | +##### params + +###### callbackContext + +`Context` + +The context for the current agent call. + +###### error + +`Error` + +The exception that was raised during model execution. + +###### llmRequest + +`LlmRequest` + +The request that was sent to the model when the error + occurred. #### Returns `Promise`\<`undefined`\> +An optional LlmResponse. If an LlmResponse is returned, it will be + used instead of propagating the error. Returning `undefined` allows + the original error to be raised. + #### Implementation of -AdkBasePlugin.onModelErrorCallback +`AdkBasePlugin.onModelErrorCallback` + +*** -#### Defined in +### onToolErrorCallback() -[src/integrations/googleAdk.ts:884](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L884) +> **onToolErrorCallback**(`params`): `Promise`\<`undefined`\> -___ +Callback executed when a tool call encounters an error. + tool: BaseTool; + toolArgs: Record\; + toolContext: Context; + result: Record\; +\}): Promise\ | undefined> \{ + return; +\} -### onToolErrorCallback +/** +Callback executed when a tool call encounters an error. -▸ **onToolErrorCallback**(`params`): `Promise`\<`undefined`\> +This callback provides an opportunity to handle tool errors gracefully, +potentially providing alternative responses or recovery mechanisms. + +Defined in: [src/integrations/googleAdk.ts:977](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L977) #### Parameters -| Name | Type | -| :------ | :------ | -| `params` | `Object` | -| `params.error` | `Error` | -| `params.tool` | `BaseTool` | -| `params.toolArgs` | `Record`\<`string`, `unknown`\> | -| `params.toolContext` | `Context` | +##### params + +###### error + +`Error` + +The exception that was raised during tool execution. + +###### tool + +`BaseTool` + +The tool instance that encountered an error. + +###### toolArgs + +`Record`\<`string`, `unknown`\> + +The arguments that were passed to the tool. + +###### toolContext + +`Context` + +The context specific to the tool execution. #### Returns `Promise`\<`undefined`\> +An optional dictionary. If a dictionary is returned, it will be + used as the tool response instead of propagating the error. Returning + `undefined` allows the original error to be raised. + #### Implementation of -AdkBasePlugin.onToolErrorCallback +`AdkBasePlugin.onToolErrorCallback` -#### Defined in +*** -[src/integrations/googleAdk.ts:977](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L977) +### onUserMessageCallback() -___ +> **onUserMessageCallback**(`_params`): `Promise`\<`undefined`\> -### onUserMessageCallback +Callback executed when a user message is received before an invocation +starts. -▸ **onUserMessageCallback**(`_params`): `Promise`\<`undefined`\> +This callback helps logging and modifying the user message before the +runner starts the invocation. + +Defined in: [src/integrations/googleAdk.ts:614](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L614) #### Parameters -| Name | Type | -| :------ | :------ | -| `_params` | `Object` | -| `_params.invocationContext` | `InvocationContext` | -| `_params.userMessage` | `Content` | +##### \_params + +###### invocationContext + +`InvocationContext` + +###### userMessage + +`Content` #### Returns `Promise`\<`undefined`\> -#### Implementation of - -AdkBasePlugin.onUserMessageCallback +An optional `Content` to be returned to the ADK. Returning a + value to replace the user message. Returning `undefined` to proceed + normally. -#### Defined in +#### Implementation of -[src/integrations/googleAdk.ts:614](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleAdk.ts#L614) \ No newline at end of file +`AdkBasePlugin.onUserMessageCallback` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/weaveclient.mdx b/weave/reference/typescript-sdk/classes/weaveclient.mdx deleted file mode 100644 index 105a7e5965..0000000000 --- a/weave/reference/typescript-sdk/classes/weaveclient.mdx +++ /dev/null @@ -1,955 +0,0 @@ ---- -title: "WeaveClient" -description: "TypeScript SDK reference" ---- - -## Table of contents - -### Constructors - -- [constructor](./weaveclient#constructor) - -### Properties - -- [projectId](./weaveclient#projectid) -- [settings](./weaveclient#settings) -- [traceServerApi](./weaveclient#traceserverapi) - -### Methods - -- [addScore](./weaveclient#addscore) -- [createCall](./weaveclient#createcall) -- [finishCall](./weaveclient#finishcall) -- [finishCallWithException](./weaveclient#finishcallwithexception) -- [get](./weaveclient#get) -- [getAgentCustomAttributes](./weaveclient#getagentcustomattributes) -- [getAgentSpanStats](./weaveclient#getagentspanstats) -- [getAgentSpans](./weaveclient#getagentspans) -- [getAgentTurn](./weaveclient#getagentturn) -- [getAgentTurns](./weaveclient#getagentturns) -- [getAgentVersions](./weaveclient#getagentversions) -- [getAgents](./weaveclient#getagents) -- [getCall](./weaveclient#getcall) -- [getCallStack](./weaveclient#getcallstack) -- [getCalls](./weaveclient#getcalls) -- [getCallsIterator](./weaveclient#getcallsiterator) -- [getCurrentAttributes](./weaveclient#getcurrentattributes) -- [linkPromptToRegistry](./weaveclient#linkprompttoregistry) -- [publish](./weaveclient#publish) -- [pushNewCall](./weaveclient#pushnewcall) -- [runWithAttributes](./weaveclient#runwithattributes) -- [runWithCallStack](./weaveclient#runwithcallstack) -- [saveCallEnd](./weaveclient#savecallend) -- [saveCallStart](./weaveclient#savecallstart) -- [saveOp](./weaveclient#saveop) -- [searchAgents](./weaveclient#searchagents) -- [serializeAudio](./weaveclient#serializeaudio) -- [updateCall](./weaveclient#updatecall) -- [waitForBatchProcessing](./weaveclient#waitforbatchprocessing) - -## Constructors - -### constructor - -• **new WeaveClient**(`«destructured»`): [`WeaveClient`](./weaveclient) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `«destructured»` | `Object` | -| › `projectId` | `string` | -| › `settings?` | `Partial`\<[`Settings`](../#settings)\> | -| › `traceServerApi` | `Api`\<`any`\> | - -#### Returns - -[`WeaveClient`](./weaveclient) - -#### Defined in - -[src/weaveClient.ts:459](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L459) - -## Properties - -### projectId - -• **projectId**: `string` - -#### Defined in - -[src/weaveClient.ts:456](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L456) - -___ - -### settings - -• **settings**: [`Settings`](../#settings) - -#### Defined in - -[src/weaveClient.ts:457](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L457) - -___ - -### traceServerApi - -• **traceServerApi**: `Api`\<`any`\> - -#### Defined in - -[src/weaveClient.ts:455](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L455) - -## Methods - -### addScore - -▸ **addScore**(`predictCallId`, `scorerCallId`, `runnableRefUri`, `scorerOutput`): `Promise`\<`string`\> - -Add a scorer result (e.g., scorer output) to a call. -Used in imperative evaluation to attach scorer results to predict calls. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `predictCallId` | `string` | ID of the predict call to attach feedback to | -| `scorerCallId` | `string` | ID of the scorer call that generated the feedback | -| `runnableRefUri` | `string` | URI of the scorer (Op or Object ref) | -| `scorerOutput` | `any` | Output of the scorer | - -#### Returns - -`Promise`\<`string`\> - -#### Defined in - -[src/weaveClient.ts:1727](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1727) - -___ - -### createCall - -▸ **createCall**(`internalCall`, `opRef`, `params`, `parameterNames`, `thisArg`, `currentCall`, `parentCall`, `startTime`, `displayName?`, `attributes?`): `Promise`\<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `internalCall` | `InternalCall` | -| `opRef` | `any` | -| `params` | `any`[] | -| `parameterNames` | `ParameterNamesOption` | -| `thisArg` | `any` | -| `currentCall` | `CallStackEntry` | -| `parentCall` | `undefined` \| `CallStackEntry` | -| `startTime` | `Date` | -| `displayName?` | `string` | -| `attributes?` | `Record`\<`string`, `any`\> | - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[src/weaveClient.ts:1570](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1570) - -___ - -### finishCall - -▸ **finishCall**(`call`, `result`, `currentCall`, `parentCall`, `summarize`, `endTime`, `startCallPromise`): `Promise`\<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `call` | `InternalCall` | -| `result` | `any` | -| `currentCall` | `CallStackEntry` | -| `parentCall` | `undefined` \| `CallStackEntry` | -| `summarize` | `undefined` \| (`result`: `any`) => `Record`\<`string`, `any`\> | -| `endTime` | `Date` | -| `startCallPromise` | `Promise`\<`void`\> | - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[src/weaveClient.ts:1630](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1630) - -___ - -### finishCallWithException - -▸ **finishCallWithException**(`call`, `error`, `currentCall`, `parentCall`, `endTime`, `startCallPromise`): `Promise`\<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `call` | `InternalCall` | -| `error` | `any` | -| `currentCall` | `CallStackEntry` | -| `parentCall` | `undefined` \| `CallStackEntry` | -| `endTime` | `Date` | -| `startCallPromise` | `Promise`\<`void`\> | - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[src/weaveClient.ts:1672](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1672) - -___ - -### get - -▸ **get**(`ref`): `Promise`\<`any`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `ref` | [`ObjectRef`](./objectref) | - -#### Returns - -`Promise`\<`any`\> - -#### Defined in - -[src/weaveClient.ts:1025](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1025) - -___ - -### getAgentCustomAttributes - -▸ **getAgentCustomAttributes**(`options`): `Promise`\<[`Response`](../#response)\<`GetAgentCustomAttributesResult`\>\> - -Discover typed custom-attribute keys observed on agent spans in the -project. Each result row is one `(source, key, value_type)` triple plus -a count of how many spans carry it, which is what the spans -query/group/stats APIs use to reference custom attrs. - -Filter the spans considered by passing `query` (a structured span -filter), `startedAfter` / `startedBefore` (ISO-8601), or both. Use -`limit` / `offset` to page through the discovered keys. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | `GetAgentCustomAttributesOptions` | - -#### Returns - -`Promise`\<[`Response`](../#response)\<`GetAgentCustomAttributesResult`\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgentCustomAttributes({ - query: { - $expr: { - $eq: [{$getField: 'agent_name'}, {$literal: 'my-agent'}], - }, - }, - startedAfter: '2026-06-15T00:00:00Z', - limit: 200, -}); - -for (const attr of resp.data.attributes ?? []) { - console.log(`${attr.source}.${attr.key} (${attr.value_type}): ${attr.span_count}`); -} -``` - -#### Defined in - -[src/weaveClient.ts:772](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L772) - -___ - -### getAgentSpanStats - -▸ **getAgentSpanStats**(`options`): `Promise`\<[`Response`](../#response)\<`GetAgentSpanStatsResult`\>\> - -Agregations over agent spans in the project, returned as rows + column -metadata suitable for time-series / bucketed visualizations. - -`start` (required) and `end` define the time window. Each entry in -`metrics` declares a field to extract and how to aggregate it (`sum`, -`avg`, `count`, percentiles, etc.). Pass `granularity` (seconds) to -bucket rows by time, or `groupBy` to break results out per agent / -provider / model / etc. `query` filters the underlying spans before -aggregation. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | `GetAgentSpanStatsOptions` | - -#### Returns - -`Promise`\<[`Response`](../#response)\<`GetAgentSpanStatsResult`\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgentSpanStats({ - start: '2026-06-10T00:00:00Z', - end: '2026-06-23T00:00:00Z', - granularity: 86400, // one row per day - metrics: [ - { - alias: 'total_input_tokens', - value_type: 'number', - aggregations: ['sum'], - value: {source: 'field', key: 'input_tokens'}, - }, - ], - groupBy: [{key: 'agent_name'}], -}); - -for (const row of resp.data.rows ?? []) { - console.log(row.started_at_bucket, row.agent_name, row.total_input_tokens); -} -``` - -#### Defined in - -[src/weaveClient.ts:621](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L621) - -___ - -### getAgentSpans - -▸ **getAgentSpans**(`options`): `Promise`\<[`Response`](../#response)\<[`GetAgentSpansResult`](../#getagentspansresult)\>\> - -Query agent spans, optionally filtered by agent name and/or a mongo-style -query expression. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | [`GetAgentSpansOptions`](../interfaces/getagentspansoptions) | - -#### Returns - -`Promise`\<[`Response`](../#response)\<[`GetAgentSpansResult`](../#getagentspansresult)\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgentSpans({agentName: 'my-agent', limit: 20}); - -for (const span of resp.data.spans) { - console.log(span.span_id, span.span_name, span.input_tokens); -} -``` - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); - -const resp = await client.getAgentSpans({ - agentName: 'my-agent', - query: { - $expr: {$gt: [{$getField: 'input_tokens'}, {$literal: 1000}]}, - }, -}); - -for (const span of resp.data.spans) { - console.log(span.span_id, span.span_name, span.input_tokens); -} -``` - -#### Defined in - -[src/weaveClient.ts:566](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L566) - -___ - -### getAgentTurn - -▸ **getAgentTurn**(`options`): `Promise`\<[`Response`](../#response)\<`AgentTraceChatRes`\>\> - -Get data (including messages) for a single turn (by traceId). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | [`GetAgentTurnOptions`](../interfaces/getagentturnoptions) | - -#### Returns - -`Promise`\<[`Response`](../#response)\<`AgentTraceChatRes`\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgentTurn({ - traceId: '01997b8a-2c89-7c4d-9d0e-2f7e5b9a1b2c', - includeFeedback: true, -}); - -console.log(resp.data.root_span_name, resp.data.total_duration_ms); - -for (const message of resp.data.messages ?? []) { - if (message.user_message) console.log('user:', message.user_message); - if (message.assistant_message) console.log('assistant:', message.assistant_message); -} -``` - -#### Defined in - -[src/weaveClient.ts:655](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L655) - -___ - -### getAgentTurns - -▸ **getAgentTurns**(`options`): `Promise`\<[`Response`](../#response)\<[`GetAgentTurnsResult`](../#getagentturnsresult)\>\> - -Get data (including messages) for many turns (by conversationId). - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | [`GetAgentTurnsOptions`](../interfaces/getagentturnsoptions) | - -#### Returns - -`Promise`\<[`Response`](../#response)\<[`GetAgentTurnsResult`](../#getagentturnsresult)\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgentTurns({ - conversationId: 'trace_c50312356de3487fa90e381c9399b5b4', - limit: 20, - includeFeedback: true, -}); - -for (const turn of resp.data.turns ?? []) { - console.log(turn.trace_id, turn.root_span_name); - for (const message of turn.messages ?? []) { - if (message.user_message) console.log('user:', message.user_message); - if (message.assistant_message) console.log('assistant:', message.assistant_message); - } -} - -console.log(`total turns: ${resp.data.total_turns}, has more: ${resp.data.has_more}`); -``` - -#### Defined in - -[src/weaveClient.ts:688](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L688) - -___ - -### getAgentVersions - -▸ **getAgentVersions**(`options`): `Promise`\<[`Response`](../#response)\<[`GetAgentVersionsResult`](../#getagentversionsresult)\>\> - -List versions for a given agent. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | [`GetAgentVersionsOptions`](../interfaces/getagentversionsoptions) | - -#### Returns - -`Promise`\<[`Response`](../#response)\<[`GetAgentVersionsResult`](../#getagentversionsresult)\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgentVersions({agentName: 'my-agent', limit: 20}); - -for (const version of resp.data.versions) { - console.log(version.agent_version, version.total_input_tokens); -} - -console.log(`total count: ${resp.data.total_count}`) -``` - -#### Defined in - -[src/weaveClient.ts:522](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L522) - -___ - -### getAgents - -▸ **getAgents**(`options?`): `Promise`\<[`Response`](../#response)\<[`GetAgentsResult`](../#getagentsresult)\>\> - -List agents with aggregated stats. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | [`GetAgentsOptions`](../interfaces/getagentsoptions) | - -#### Returns - -`Promise`\<[`Response`](../#response)\<[`GetAgentsResult`](../#getagentsresult)\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.getAgents({limit: 20}); - -for (const agent of resp.data.agents) { - console.log(agent.agent_name, agent.total_input_tokens); -} - -console.log(`total count: ${resp.data.total_count}`) -``` - -#### Defined in - -[src/weaveClient.ts:488](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L488) - -___ - -### getCall - -▸ **getCall**(`callId`, `includeCosts?`): `Promise`\<`Call`\> - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `callId` | `string` | `undefined` | -| `includeCosts` | `boolean` | `false` | - -#### Returns - -`Promise`\<`Call`\> - -#### Defined in - -[src/weaveClient.ts:902](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L902) - -___ - -### getCallStack - -▸ **getCallStack**(): `CallStack` - -#### Returns - -`CallStack` - -#### Defined in - -[src/weaveClient.ts:1482](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1482) - -___ - -### getCalls - -▸ **getCalls**(`options?`): `Promise`\<`Call`[]\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | [`GetCallsOptions`](../interfaces/getcallsoptions) | - -#### Returns - -`Promise`\<`Call`[]\> - -#### Defined in - -[src/weaveClient.ts:935](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L935) - -▸ **getCalls**(`options?`, `includeCosts?`, `limit?`): `Promise`\<`Call`[]\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | [`CallsFilter`](../interfaces/callsfilter) | -| `includeCosts?` | `boolean` | -| `limit?` | `number` | - -#### Returns - -`Promise`\<`Call`[]\> - -#### Defined in - -[src/weaveClient.ts:936](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L936) - -___ - -### getCallsIterator - -▸ **getCallsIterator**(`options?`, `includeCosts?`, `limit?`): `AsyncIterableIterator`\<[`CallSchema`](../interfaces/callschema), `any`, `any`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | [`CallsFilter`](../interfaces/callsfilter) | -| `includeCosts?` | `boolean` | -| `limit?` | `number` | - -#### Returns - -`AsyncIterableIterator`\<[`CallSchema`](../interfaces/callschema), `any`, `any`\> - -#### Defined in - -[src/weaveClient.ts:957](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L957) - -▸ **getCallsIterator**(`options?`): `AsyncIterableIterator`\<[`CallSchema`](../interfaces/callschema), `any`, `any`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | [`GetCallsOptions`](../interfaces/getcallsoptions) | - -#### Returns - -`AsyncIterableIterator`\<[`CallSchema`](../interfaces/callschema), `any`, `any`\> - -#### Defined in - -[src/weaveClient.ts:962](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L962) - -___ - -### getCurrentAttributes - -▸ **getCurrentAttributes**(): `Record`\<`string`, `any`\> - -#### Returns - -`Record`\<`string`, `any`\> - -#### Defined in - -[src/weaveClient.ts:1486](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1486) - -___ - -### linkPromptToRegistry - -▸ **linkPromptToRegistry**(`prompt`, `options`): `Promise`\<`LinkAssetToRegistryRes`\> - -Link a published prompt version into a registry portfolio. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `prompt` | `RegistryLinkable` | -| `options` | `LinkPromptToRegistryOptions` | - -#### Returns - -`Promise`\<`LinkAssetToRegistryRes`\> - -#### Defined in - -[src/weaveClient.ts:1181](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1181) - -___ - -### publish - -▸ **publish**(`obj`, `objId?`): `Promise`\<[`ObjectRef`](./objectref)\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `obj` | `any` | -| `objId?` | `string` | - -#### Returns - -`Promise`\<[`ObjectRef`](./objectref)\> - -#### Defined in - -[src/weaveClient.ts:890](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L890) - -___ - -### pushNewCall - -▸ **pushNewCall**(): `Object` - -#### Returns - -`Object` - -| Name | Type | -| :------ | :------ | -| `currentCall` | `CallStackEntry` | -| `newStack` | `CallStack` | -| `parentCall?` | `CallStackEntry` | - -#### Defined in - -[src/weaveClient.ts:1490](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1490) - -___ - -### runWithAttributes - -▸ **runWithAttributes**\<`T`\>(`attributes`, `fn`): `T` - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `attributes` | `Record`\<`string`, `any`\> | -| `fn` | () => `T` | - -#### Returns - -`T` - -#### Defined in - -[src/weaveClient.ts:1498](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1498) - -___ - -### runWithCallStack - -▸ **runWithCallStack**\<`T`\>(`callStack`, `fn`): `T` - -#### Type parameters - -| Name | -| :------ | -| `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `callStack` | `CallStack` | -| `fn` | () => `T` | - -#### Returns - -`T` - -#### Defined in - -[src/weaveClient.ts:1494](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1494) - -___ - -### saveCallEnd - -▸ **saveCallEnd**(`callEnd`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `callEnd` | `EndedCallSchemaForInsert` | - -#### Returns - -`void` - -#### Defined in - -[src/weaveClient.ts:1477](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1477) - -___ - -### saveCallStart - -▸ **saveCallStart**(`callStart`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `callStart` | `StartedCallSchemaForInsert` | - -#### Returns - -`void` - -#### Defined in - -[src/weaveClient.ts:1472](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1472) - -___ - -### saveOp - -▸ **saveOp**(`op`, `objId?`): `Promise`\<`OpRef`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `op` | [`Op`](../#op)\<(...`args`: `any`[]) => `any`\> | -| `objId?` | `string` | - -#### Returns - -`Promise`\<`OpRef`\> - -#### Defined in - -[src/weaveClient.ts:1537](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1537) - -___ - -### searchAgents - -▸ **searchAgents**(`options`): `Promise`\<[`Response`](../#response)\<`SearchAgentsResult`\>\> - -Full-text search across agent messages in the project. Returns hits -grouped by conversation, with a preview of each matched message. - -`query` is the full-text search term. Pass an empty string to retrieve -all messages matching the structured filters (`agentName`, -`conversationId`, `traceId`) without text matching. Use `limit` / -`offset` to page through results. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | `SearchAgentsOptions` | - -#### Returns - -`Promise`\<[`Response`](../#response)\<`SearchAgentsResult`\>\> - -`Example` - -```ts twoslash -// @noErrors -const client = await weave.init('entity/project'); -const resp = await client.searchAgents({ - query: 'Liverpool', - agentName: 'Assistant', - limit: 20, -}); - -for (const conversation of resp.data.results ?? []) { - console.log(`${conversation.conversation_id} (${conversation.agent_name})`); - for (const match of conversation.matched_messages) { - console.log(` [${match.role}] ${match.content_preview}`); - } -} - -console.log(`total conversations: ${resp.data.total_conversations}`); -``` - -#### Defined in - -[src/weaveClient.ts:730](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L730) - -___ - -### serializeAudio - -▸ **serializeAudio**(`data`, `audioType?`): `Promise`\<`SerializedFileBlob`\> - -Upload raw audio bytes to the Weave content store and return the -`CustomWeaveType` placeholder that can be embedded in a call output. - -Use this when building call outputs manually (e.g. via `saveCallEnd`) -where the automatic serialization pipeline from `finishCall` is not used. - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `data` | `Buffer`\<`ArrayBufferLike`\> | `undefined` | Raw audio bytes (WAV for best browser compatibility) | -| `audioType` | ``"wav"`` | `DEFAULT_AUDIO_TYPE` | File format — currently only 'wav' is supported | - -#### Returns - -`Promise`\<`SerializedFileBlob`\> - -#### Defined in - -[src/weaveClient.ts:1424](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1424) - -___ - -### updateCall - -▸ **updateCall**(`callId`, `displayName`): `Promise`\<`void`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `callId` | `string` | -| `displayName` | `string` | - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[src/weaveClient.ts:1710](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1710) - -___ - -### waitForBatchProcessing - -▸ **waitForBatchProcessing**(): `Promise`\<`void`\> - -#### Returns - -`Promise`\<`void`\> - -#### Defined in - -[src/weaveClient.ts:801](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L801) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/classes/weaveobject.mdx b/weave/reference/typescript-sdk/classes/weaveobject.mdx index a03d35f163..0ad2c5ac3e 100644 --- a/weave/reference/typescript-sdk/classes/weaveobject.mdx +++ b/weave/reference/typescript-sdk/classes/weaveobject.mdx @@ -3,101 +3,75 @@ title: "WeaveObject" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/weaveObject.ts:70](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L70) -- `WeaveObject` +## Extended by - ↳ [`Dataset`](./dataset) - - ↳ [`Evaluation`](./evaluation) - -## Table of contents - -### Constructors - -- [constructor](./weaveobject#constructor) - -### Properties - -- [\_\_savedRef](./weaveobject#__savedref) - -### Accessors - -- [description](./weaveobject#description) -- [name](./weaveobject#name) - -### Methods - -- [saveAttrs](./weaveobject#saveattrs) +- [`Dataset`](./dataset) +- [`Evaluation`](./evaluation) ## Constructors -### constructor +### Constructor -• **new WeaveObject**(`_baseParameters`): [`WeaveObject`](./weaveobject) +> **new WeaveObject**(`_baseParameters`): `WeaveObject` -#### Parameters +Defined in: [src/weaveObject.ts:73](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L73) -| Name | Type | -| :------ | :------ | -| `_baseParameters` | `WeaveObjectParameters` | +#### Parameters -#### Returns +##### \_baseParameters -[`WeaveObject`](./weaveobject) +`WeaveObjectParameters` -#### Defined in +#### Returns -[src/weaveObject.ts:73](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L73) +`WeaveObject` ## Properties ### \_\_savedRef -• `Optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> +> `optional` **\_\_savedRef**: [`ObjectRef`](./objectref) \| `Promise`\<[`ObjectRef`](./objectref)\> -#### Defined in - -[src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) +Defined in: [src/weaveObject.ts:71](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L71) ## Accessors ### description -• `get` **description**(): `undefined` \| `string` +#### Get Signature -#### Returns +> **get** **description**(): `string` \| `undefined` -`undefined` \| `string` +Defined in: [src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) -#### Defined in +##### Returns -[src/weaveObject.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L98) +`string` \| `undefined` -___ +*** ### name -• `get` **name**(): `string` +#### Get Signature -#### Returns +> **get** **name**(): `string` -`string` +Defined in: [src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) -#### Defined in +##### Returns -[src/weaveObject.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L94) +`string` ## Methods -### saveAttrs +### saveAttrs() -▸ **saveAttrs**(): `Object` +> **saveAttrs**(): `object` -#### Returns +Defined in: [src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) -`Object` - -#### Defined in +#### Returns -[src/weaveObject.ts:75](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveObject.ts#L75) \ No newline at end of file +`object` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/createopenaiagentstracingprocessor.mdx b/weave/reference/typescript-sdk/functions/createopenaiagentstracingprocessor.mdx index 796050e08b..7ef150cedc 100644 --- a/weave/reference/typescript-sdk/functions/createopenaiagentstracingprocessor.mdx +++ b/weave/reference/typescript-sdk/functions/createopenaiagentstracingprocessor.mdx @@ -3,19 +3,19 @@ title: "createOpenAIAgentsTracingProcessor" description: "TypeScript SDK reference" --- -# createOpenAIAgentsTracingProcessor - -▸ **createOpenAIAgentsTracingProcessor**(): `TracingProcessor` +> **createOpenAIAgentsTracingProcessor**(): `TracingProcessor` Create a new Weave tracing processor for OpenAI Agents. -#### Returns +Defined in: [src/integrations/openai.agent.ts:102](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.agent.ts#L102) + +## Returns `TracingProcessor` A TracingProcessor instance that can be registered with OpenAI Agents -`Example` +## Example ```typescript twoslash // @noErrors @@ -24,10 +24,4 @@ import { createOpenAIAgentsTracingProcessor } from 'weave'; const processor = createOpenAIAgentsTracingProcessor(); addTraceProcessor(processor); -``` - -#### Defined in - -[src/integrations/openai.agent.ts:102](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.agent.ts#L102) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/createotelextension.mdx b/weave/reference/typescript-sdk/functions/createotelextension.mdx index 06d4a5a479..923c416c35 100644 --- a/weave/reference/typescript-sdk/functions/createotelextension.mdx +++ b/weave/reference/typescript-sdk/functions/createotelextension.mdx @@ -3,9 +3,7 @@ title: "createOtelExtension" description: "TypeScript SDK reference" --- -# createOtelExtension - -▸ **createOtelExtension**(`opts?`): (`pi`: `PiExtensionApi`) => `void` +> **createOtelExtension**(`opts?`): (`pi`) => `void` Creates a pi coding agent extension that emits OTEL spans for the full agent lifecycle, conforming to the GenAI semantic conventions. @@ -14,39 +12,23 @@ When `weave.init(...)` has been called, spans are automatically exported to the Weave trace server at `/agents/otel/v1/traces`. Otherwise, pass a custom `tracer` in `opts`. -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | `OtelExtensionOptions` | - -#### Returns - -`fn` +Defined in: [src/integrations/piCodingAgent.ts:654](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/piCodingAgent.ts#L654) -▸ (`pi`): `void` +## Parameters -##### Parameters +### opts? -| Name | Type | -| :------ | :------ | -| `pi` | `PiExtensionApi` | +`OtelExtensionOptions` = `{}` -##### Returns +## Returns -`void` +(`pi`) => `void` -`Example` +## Example ```typescript twoslash // @noErrors const resourceLoader = new DefaultResourceLoader({ extensionFactories: [createOtelExtension()], }); -``` - -#### Defined in - -[src/integrations/piCodingAgent.ts:654](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/piCodingAgent.ts#L654) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/endconversation.mdx b/weave/reference/typescript-sdk/functions/endconversation.mdx index 09278bbdef..fa4d1be980 100644 --- a/weave/reference/typescript-sdk/functions/endconversation.mdx +++ b/weave/reference/typescript-sdk/functions/endconversation.mdx @@ -3,38 +3,30 @@ title: "endConversation" description: "TypeScript SDK reference" --- -# endConversation - -▸ **endConversation**(`opts?`): `void` +> **endConversation**(`opts?`): `void` End the current Conversation. No-op if no Conversation is active. -#### Parameters +Defined in: [src/genai/api.ts:159](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L159) + +## Parameters -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | +### opts? -#### Returns +`SpanEndOptions` + +## Returns `void` -`Example` +## Examples ```ts twoslash // @noErrors weave.endConversation(); ``` -`Example` - ```ts twoslash // @noErrors weave.endConversation({endTime: new Date('2026-05-29T10:00:01.700Z')}); -``` - -#### Defined in - -[src/genai/api.ts:159](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L159) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/endllm.mdx b/weave/reference/typescript-sdk/functions/endllm.mdx index b4e90445e5..8a7da69ecc 100644 --- a/weave/reference/typescript-sdk/functions/endllm.mdx +++ b/weave/reference/typescript-sdk/functions/endllm.mdx @@ -3,45 +3,35 @@ title: "endLLM" description: "TypeScript SDK reference" --- -# endLLM - -▸ **endLLM**(`opts?`): `void` +> **endLLM**(`opts?`): `void` End the current LLM. No-op if no LLM is active. -#### Parameters +Defined in: [src/genai/api.ts:202](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L202) + +## Parameters + +### opts? -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | +`SpanEndOptions` -#### Returns +## Returns `void` -`Example` +## Examples ```ts twoslash // @noErrors weave.endLLM(); ``` -`Example` - ```ts twoslash // @noErrors weave.endLLM({endTime: new Date('2026-05-29T10:00:00.800Z')}); ``` -`Example` - ```ts twoslash // @noErrors weave.endLLM({error: new Error('llm call failed')}); -``` - -#### Defined in - -[src/genai/api.ts:202](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L202) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/endsession.mdx b/weave/reference/typescript-sdk/functions/endsession.mdx deleted file mode 100644 index 455b1406ad..0000000000 --- a/weave/reference/typescript-sdk/functions/endsession.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "endSession" -description: "TypeScript SDK reference" ---- - -# endSession - - - **Deprecated.** Use [endConversation](./endconversation) instead. - - -▸ **endSession**(`opts?`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | - -#### Returns - -`void` - -#### Defined in - -[src/genai/api.ts:169](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L169) - -___ diff --git a/weave/reference/typescript-sdk/functions/endturn.mdx b/weave/reference/typescript-sdk/functions/endturn.mdx index 564d633377..14b67d7c60 100644 --- a/weave/reference/typescript-sdk/functions/endturn.mdx +++ b/weave/reference/typescript-sdk/functions/endturn.mdx @@ -3,45 +3,35 @@ title: "endTurn" description: "TypeScript SDK reference" --- -# endTurn - -▸ **endTurn**(`opts?`): `void` +> **endTurn**(`opts?`): `void` End the current Turn. No-op if no Turn is active. -#### Parameters +Defined in: [src/genai/api.ts:183](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L183) + +## Parameters + +### opts? -| Name | Type | -| :------ | :------ | -| `opts?` | `SpanEndOptions` | +`SpanEndOptions` -#### Returns +## Returns `void` -`Example` +## Examples ```ts twoslash // @noErrors weave.endTurn(); ``` -`Example` - ```ts twoslash // @noErrors weave.endTurn({endTime: new Date('2026-05-29T10:00:01.700Z')}); ``` -`Example` - ```ts twoslash // @noErrors weave.endTurn({error: new Error('agent loop diverged')}); -``` - -#### Defined in - -[src/genai/api.ts:183](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L183) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/flushotel.mdx b/weave/reference/typescript-sdk/functions/flushotel.mdx index ffbd3f13b4..80983c4584 100644 --- a/weave/reference/typescript-sdk/functions/flushotel.mdx +++ b/weave/reference/typescript-sdk/functions/flushotel.mdx @@ -3,9 +3,7 @@ title: "flushOTel" description: "TypeScript SDK reference" --- -# flushOTel - -▸ **flushOTel**(): `Promise`\<`void`\> +> **flushOTel**(): `Promise`\<`void`\> Force-flush any GenAI spans buffered by the active span processor. @@ -18,12 +16,8 @@ Call before process exit when using `'simple'` or any other processor that may have in-flight work, or in tests that need to observe exported spans synchronously. -#### Returns - -`Promise`\<`void`\> - -#### Defined in +Defined in: [src/genai/flush.ts:15](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/flush.ts#L15) -[src/genai/flush.ts:15](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/flush.ts#L15) +## Returns -___ +`Promise`\<`void`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/getcurrentconversation.mdx b/weave/reference/typescript-sdk/functions/getcurrentconversation.mdx index 2d91f3b2df..8d8b3d3dcb 100644 --- a/weave/reference/typescript-sdk/functions/getcurrentconversation.mdx +++ b/weave/reference/typescript-sdk/functions/getcurrentconversation.mdx @@ -3,18 +3,12 @@ title: "getCurrentConversation" description: "TypeScript SDK reference" --- -# getCurrentConversation - -▸ **getCurrentConversation**(): [`Conversation`](../classes/conversation) \| `undefined` +> **getCurrentConversation**(): [`Conversation`](../interfaces/conversation) \| `undefined` Returns the current Conversation, or undefined. -#### Returns - -[`Conversation`](../classes/conversation) \| `undefined` - -#### Defined in +Defined in: [src/genai/context.ts:59](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L59) -[src/genai/context.ts:59](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L59) +## Returns -___ +[`Conversation`](../interfaces/conversation) \| `undefined` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/getcurrentllm.mdx b/weave/reference/typescript-sdk/functions/getcurrentllm.mdx index c85f21f5de..a1cc84c732 100644 --- a/weave/reference/typescript-sdk/functions/getcurrentllm.mdx +++ b/weave/reference/typescript-sdk/functions/getcurrentllm.mdx @@ -3,18 +3,12 @@ title: "getCurrentLLM" description: "TypeScript SDK reference" --- -# getCurrentLLM - -▸ **getCurrentLLM**(): [`LLM`](../classes/llm) \| `undefined` +> **getCurrentLLM**(): [`LLM`](../interfaces/llm) \| `undefined` Returns the current LLM, or undefined. -#### Returns - -[`LLM`](../classes/llm) \| `undefined` - -#### Defined in +Defined in: [src/genai/context.ts:72](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L72) -[src/genai/context.ts:72](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L72) +## Returns -___ +[`LLM`](../interfaces/llm) \| `undefined` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/getcurrentsession.mdx b/weave/reference/typescript-sdk/functions/getcurrentsession.mdx deleted file mode 100644 index 92ae9ca876..0000000000 --- a/weave/reference/typescript-sdk/functions/getcurrentsession.mdx +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: "getCurrentSession" -description: "TypeScript SDK reference" ---- - -# getCurrentSession - - - **Deprecated.** Use [getCurrentConversation](./getcurrentconversation) instead. - - -▸ **getCurrentSession**(): [`Conversation`](../classes/conversation) \| `undefined` - -#### Returns - -[`Conversation`](../classes/conversation) \| `undefined` - -#### Defined in - -[src/genai/context.ts:64](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L64) - -___ diff --git a/weave/reference/typescript-sdk/functions/getcurrentturn.mdx b/weave/reference/typescript-sdk/functions/getcurrentturn.mdx index 7735ec78a7..712e1dae72 100644 --- a/weave/reference/typescript-sdk/functions/getcurrentturn.mdx +++ b/weave/reference/typescript-sdk/functions/getcurrentturn.mdx @@ -3,18 +3,12 @@ title: "getCurrentTurn" description: "TypeScript SDK reference" --- -# getCurrentTurn - -▸ **getCurrentTurn**(): [`Turn`](../classes/turn) \| `undefined` +> **getCurrentTurn**(): [`Turn`](../interfaces/turn) \| `undefined` Returns the current Turn, or undefined. -#### Returns - -[`Turn`](../classes/turn) \| `undefined` - -#### Defined in +Defined in: [src/genai/context.ts:67](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L67) -[src/genai/context.ts:67](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L67) +## Returns -___ +[`Turn`](../interfaces/turn) \| `undefined` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/init.mdx b/weave/reference/typescript-sdk/functions/init.mdx index 44b7df9ba8..89090b54a0 100644 --- a/weave/reference/typescript-sdk/functions/init.mdx +++ b/weave/reference/typescript-sdk/functions/init.mdx @@ -3,31 +3,35 @@ title: "init" description: "TypeScript SDK reference" --- -# init - -▸ **init**(`project`, `settings?`): `Promise`\<[`WeaveClient`](../classes/weaveclient)\> +> **init**(`project`, `settings?`): `Promise`\<[`WeaveClient`](../interfaces/weaveclient)\> Initialize the Weave client, which is required for weave tracing to work. -#### Parameters +Defined in: [src/clientApi.ts:87](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L87) -| Name | Type | Description | -| :------ | :------ | :------ | -| `project` | `string` | The W&B project name (can be project or entity/project). If you don't specify a W&B team (e.g., 'team/project'), your default entity is used. To find or update your default entity, refer to User Settings at https://docs.wandb.ai/platform/app/settings-page/user-settings#default-team | -| `settings?` | `Partial`\<[`Settings`](../type-aliases/settings)\> | (Optional) Weave tracing settings | +## Parameters -#### Returns +### project -`Promise`\<[`WeaveClient`](../classes/weaveclient)\> +`string` -A promise that resolves to the initialized Weave client. +The W&B project name (can be project or entity/project). If you don't + specify a W&B team (e.g., 'team/project'), your default entity is used. + To find or update your default entity, refer to User Settings at + https://docs.wandb.ai/platform/app/settings-page/user-settings#default-team + +### settings? -`Throws` +`Partial`\<[`Settings`](../type-aliases/settings)\> -If the initialization fails +(Optional) Weave tracing settings -#### Defined in +## Returns + +`Promise`\<[`WeaveClient`](../interfaces/weaveclient)\> + +A promise that resolves to the initialized Weave client. -[src/clientApi.ts:87](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L87) +## Throws -___ +If the initialization fails \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/instrumentopenaiagents.mdx b/weave/reference/typescript-sdk/functions/instrumentopenaiagents.mdx index 5282596464..b37cbc458f 100644 --- a/weave/reference/typescript-sdk/functions/instrumentopenaiagents.mdx +++ b/weave/reference/typescript-sdk/functions/instrumentopenaiagents.mdx @@ -3,9 +3,7 @@ title: "instrumentOpenAIAgents" description: "TypeScript SDK reference" --- -# instrumentOpenAIAgents - -▸ **instrumentOpenAIAgents**(): `Promise`\<`boolean`\> +> **instrumentOpenAIAgents**(): `Promise`\<`boolean`\> Manually register Weave tracing with OpenAI Agents if the package is available. @@ -18,13 +16,15 @@ This function attempts to dynamically import @openai/agents from the consumer's and registers a TracingProcessor. If the package is not installed, it returns false without throwing an error. -#### Returns +Defined in: [src/integrations/openai.agent.ts:169](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.agent.ts#L169) + +## Returns `Promise`\<`boolean`\> `Promise` - `true` if registration succeeded, `false` if `@openai/agents` not available -`Example` +## Examples ```typescript twoslash // @noErrors @@ -38,8 +38,6 @@ const agent = new Agent({ ... }); await agent.run(input); // Automatically traced in Weave ``` -`Example` - ```typescript twoslash // @noErrors // ⚠️ Only needed for edge cases where automatic hooks don't work @@ -51,7 +49,7 @@ if (!registered) { } ``` -`Remarks` +## Remarks **How automatic instrumentation works**: When you import Weave, it registers module loader hooks via `addCJSInstrumentation()` and `addESMInstrumentation()`. When your code later @@ -72,10 +70,4 @@ import { createOpenAIAgentsTracingProcessor } from 'weave'; const processor = createOpenAIAgentsTracingProcessor(); addTraceProcessor(processor); -``` - -#### Defined in - -[src/integrations/openai.agent.ts:169](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.agent.ts#L169) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/login.mdx b/weave/reference/typescript-sdk/functions/login.mdx index a9aa82b20a..6149cd1bc3 100644 --- a/weave/reference/typescript-sdk/functions/login.mdx +++ b/weave/reference/typescript-sdk/functions/login.mdx @@ -3,31 +3,32 @@ title: "login" description: "TypeScript SDK reference" --- -# login - -▸ **login**(`apiKey`, `host?`): `Promise`\<`void`\> +> **login**(`apiKey`, `host?`): `Promise`\<`void`\> Log in to Weights & Biases (W&B) using the provided API key. This function attempts to save the credentials to your netrc file for future use, but will continue even if it cannot write to the file system. -#### Parameters +Defined in: [src/clientApi.ts:27](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L27) -| Name | Type | Description | -| :------ | :------ | :------ | -| `apiKey` | `string` | Your W&B API key. | -| `host?` | `string` | (Optional) The host name (usually only needed if you're using a custom W&B server). | +## Parameters -#### Returns +### apiKey -`Promise`\<`void`\> +`string` + +Your W&B API key. -`Throws` +### host? -If the API key is not specified or if the connection to the weave trace server cannot be verified. +`string` -#### Defined in +(Optional) The host name (usually only needed if you're using a custom W&B server). + +## Returns + +`Promise`\<`void`\> -[src/clientApi.ts:27](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L27) +## Throws -___ +If the API key is not specified or if the connection to the weave trace server cannot be verified. \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/op.mdx b/weave/reference/typescript-sdk/functions/op.mdx index 0009a0a627..bb9dab9be8 100644 --- a/weave/reference/typescript-sdk/functions/op.mdx +++ b/weave/reference/typescript-sdk/functions/op.mdx @@ -3,110 +3,124 @@ title: "op" description: "TypeScript SDK reference" --- -# op +## Call Signature -▸ **op**\<`T`\>(`fn`, `options?`): [`Op`](../type-aliases/op)\<`T`\> +> **op**\<`T`\>(`fn`, `options?`): [`Op`](../type-aliases/op)\<`T`\> -#### Type parameters +Defined in: [src/op.ts:380](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L380) -| Name | Type | -| :------ | :------ | -| `T` | extends (...`args`: `any`[]) => `any` | +### Type Parameters -#### Parameters +#### T -| Name | Type | -| :------ | :------ | -| `fn` | `T` | -| `options?` | `OpOptions`\<`T`\> | +`T` *extends* (...`args`) => `any` -#### Returns +### Parameters + +#### fn + +`T` + +#### options? + +`OpOptions`\<`T`\> + +### Returns [`Op`](../type-aliases/op)\<`T`\> -#### Defined in +## Call Signature + +> **op**\<`T`\>(`thisArg`, `fn`, `options?`): [`Op`](../type-aliases/op)\<`T`\> + +Defined in: [src/op.ts:385](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L385) + +### Type Parameters + +#### T + +`T` *extends* (...`args`) => `any` + +### Parameters -[src/op.ts:380](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L380) +#### thisArg -▸ **op**\<`T`\>(`thisArg`, `fn`, `options?`): [`Op`](../type-aliases/op)\<`T`\> +`any` -#### Type parameters +#### fn -| Name | Type | -| :------ | :------ | -| `T` | extends (...`args`: `any`[]) => `any` | +`T` -#### Parameters +#### options? -| Name | Type | -| :------ | :------ | -| `thisArg` | `any` | -| `fn` | `T` | -| `options?` | `OpOptions`\<`T`\> | +`OpOptions`\<`T`\> -#### Returns +### Returns [`Op`](../type-aliases/op)\<`T`\> -#### Defined in +## Call Signature -[src/op.ts:385](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L385) +> **op**(`target`, `propertyKey`, `descriptor`): `TypedPropertyDescriptor`\<`any`\> -▸ **op**(`target`, `propertyKey`, `descriptor`): `TypedPropertyDescriptor`\<`any`\> +Defined in: [src/op.ts:391](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L391) -#### Parameters +### Parameters -| Name | Type | -| :------ | :------ | -| `target` | `object` | -| `propertyKey` | `string` \| `symbol` | -| `descriptor` | `TypedPropertyDescriptor`\<`any`\> | +#### target -#### Returns +`object` + +#### propertyKey + +`string` \| `symbol` + +#### descriptor `TypedPropertyDescriptor`\<`any`\> -#### Defined in +### Returns -[src/op.ts:391](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L391) +`TypedPropertyDescriptor`\<`any`\> -▸ **op**\<`T`\>(`value`, `context`): [`Op`](../type-aliases/op)\<`T`\> +## Call Signature -#### Type parameters +> **op**\<`T`\>(`value`, `context`): [`Op`](../type-aliases/op)\<`T`\> -| Name | Type | -| :------ | :------ | -| `T` | extends (...`args`: `any`[]) => `any` | +Defined in: [src/op.ts:397](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L397) -#### Parameters +### Type Parameters -| Name | Type | -| :------ | :------ | -| `value` | `T` | -| `context` | `MethodDecoratorContext` | +#### T -#### Returns +`T` *extends* (...`args`) => `any` -[`Op`](../type-aliases/op)\<`T`\> +### Parameters -#### Defined in +#### value -[src/op.ts:397](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L397) +`T` + +#### context + +`MethodDecoratorContext` + +### Returns + +[`Op`](../type-aliases/op)\<`T`\> -▸ **op**(`options`): `MethodDecorator` +## Call Signature -#### Parameters +> **op**(`options`): `MethodDecorator` -| Name | Type | -| :------ | :------ | -| `options` | `Partial`\<`OpOptions`\<`any`\>\> | +Defined in: [src/op.ts:402](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L402) -#### Returns +### Parameters -`MethodDecorator` +#### options -#### Defined in +`Partial`\<`OpOptions`\<`any`\>\> -[src/op.ts:402](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/op.ts#L402) +### Returns -___ +`MethodDecorator` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/patchrealtimesession.mdx b/weave/reference/typescript-sdk/functions/patchrealtimesession.mdx index 681e41c6b9..5d5aed33c2 100644 --- a/weave/reference/typescript-sdk/functions/patchrealtimesession.mdx +++ b/weave/reference/typescript-sdk/functions/patchrealtimesession.mdx @@ -3,9 +3,7 @@ title: "patchRealtimeSession" description: "TypeScript SDK reference" --- -# patchRealtimeSession - -▸ **patchRealtimeSession**(): `Promise`\<`boolean`\> +> **patchRealtimeSession**(): `Promise`\<`boolean`\> Manually patch the `RealtimeSession` class from `@openai/agents-realtime` so that every new instance is automatically traced by Weave. @@ -18,24 +16,20 @@ imports, bundlers that bypass hooks). Call this **once** at app startup, before any `RealtimeSession` is constructed. The function is idempotent — safe to call multiple times. -#### Returns +Defined in: [src/integrations/openai.realtime.agent.ts:836](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.realtime.agent.ts#L836) + +## Returns `Promise`\<`boolean`\> `true` if the patch was applied (or was already in place), `false` if `@openai/agents-realtime` could not be loaded. -`Example` +## Example ```typescript twoslash // @noErrors import { patchRealtimeSession } from 'weave'; await patchRealtimeSession(); // Every new RealtimeSession(...) is now auto-instrumented -``` - -#### Defined in - -[src/integrations/openai.realtime.agent.ts:836](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.realtime.agent.ts#L836) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/requirecurrentcallstackentry.mdx b/weave/reference/typescript-sdk/functions/requirecurrentcallstackentry.mdx index 9df530ab34..605747abce 100644 --- a/weave/reference/typescript-sdk/functions/requirecurrentcallstackentry.mdx +++ b/weave/reference/typescript-sdk/functions/requirecurrentcallstackentry.mdx @@ -3,16 +3,10 @@ title: "requireCurrentCallStackEntry" description: "TypeScript SDK reference" --- -# requireCurrentCallStackEntry +> **requireCurrentCallStackEntry**(): `CallStackEntry` -▸ **requireCurrentCallStackEntry**(): `CallStackEntry` +Defined in: [src/clientApi.ts:163](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L163) -#### Returns +## Returns -`CallStackEntry` - -#### Defined in - -[src/clientApi.ts:163](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L163) - -___ +`CallStackEntry` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/requirecurrentchildsummary.mdx b/weave/reference/typescript-sdk/functions/requirecurrentchildsummary.mdx index 0ad477f627..9b5243bbc2 100644 --- a/weave/reference/typescript-sdk/functions/requirecurrentchildsummary.mdx +++ b/weave/reference/typescript-sdk/functions/requirecurrentchildsummary.mdx @@ -3,16 +3,10 @@ title: "requireCurrentChildSummary" description: "TypeScript SDK reference" --- -# requireCurrentChildSummary +> **requireCurrentChildSummary**(): `object` -▸ **requireCurrentChildSummary**(): `Object` +Defined in: [src/clientApi.ts:175](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L175) -#### Returns +## Returns -`Object` - -#### Defined in - -[src/clientApi.ts:175](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L175) - -___ +`object` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/runisolated.mdx b/weave/reference/typescript-sdk/functions/runisolated.mdx index f8739a0556..d32f53ab65 100644 --- a/weave/reference/typescript-sdk/functions/runisolated.mdx +++ b/weave/reference/typescript-sdk/functions/runisolated.mdx @@ -3,9 +3,7 @@ title: "runIsolated" description: "TypeScript SDK reference" --- -# runIsolated - -▸ **runIsolated**\<`T`\>(`fn`): `T` +> **runIsolated**\<`T`\>(`fn`): `T` Run `fn` in a fresh, isolated GenAI state frame. Any Conversation / Turn / LLM started inside `fn` lives in this frame only — it does not clash with @@ -24,24 +22,20 @@ Use this to safely run parallel GenAI work: Sequential single-flight usage doesn't require this wrapper — the process-wide default state handles it. -#### Type parameters +Defined in: [src/genai/context.ts:54](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L54) -| Name | -| :------ | -| `T` | +## Type Parameters -#### Parameters +### T -| Name | Type | -| :------ | :------ | -| `fn` | () => `T` | +`T` -#### Returns +## Parameters -`T` +### fn -#### Defined in +() => `T` -[src/genai/context.ts:54](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L54) +## Returns -___ +`T` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/startconversation.mdx b/weave/reference/typescript-sdk/functions/startconversation.mdx index e0670647fe..bf6f668f73 100644 --- a/weave/reference/typescript-sdk/functions/startconversation.mdx +++ b/weave/reference/typescript-sdk/functions/startconversation.mdx @@ -3,9 +3,7 @@ title: "startConversation" description: "TypeScript SDK reference" --- -# startConversation - -▸ **startConversation**(`opts?`): [`Conversation`](../classes/conversation) +> **startConversation**(`opts?`): [`Conversation`](../interfaces/conversation) Start a new Conversation and install it as the current conversation. Subsequent calls to `startTurn` will pick it up automatically. @@ -13,25 +11,25 @@ Subsequent calls to `startTurn` will pick it up automatically. Pass `attributes` to stamp custom (non-semconv) attributes on every span the conversation emits. -#### Parameters +Defined in: [src/genai/api.ts:26](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L26) + +## Parameters -| Name | Type | -| :------ | :------ | -| `opts` | [`ConversationInit`](../interfaces/conversationinit) | +### opts? -#### Returns +[`ConversationInit`](../interfaces/conversationinit) = `{}` -[`Conversation`](../classes/conversation) +## Returns -`Example` +[`Conversation`](../interfaces/conversation) + +## Examples ```ts twoslash // @noErrors weave.startConversation({agentName: 'research-bot'}); ``` -`Example` - ```ts twoslash // @noErrors weave.startConversation({ @@ -39,10 +37,4 @@ weave.startConversation({ conversationId: '019efa53-8a65-711c-b4c1-7c1cb72c0bb7', attributes: {'myagent.version': '1.23'}, }); -``` - -#### Defined in - -[src/genai/api.ts:26](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L26) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/startllm.mdx b/weave/reference/typescript-sdk/functions/startllm.mdx index b0eb5c8b7b..ae09710fe8 100644 --- a/weave/reference/typescript-sdk/functions/startllm.mdx +++ b/weave/reference/typescript-sdk/functions/startllm.mdx @@ -3,32 +3,30 @@ title: "startLLM" description: "TypeScript SDK reference" --- -# startLLM - -▸ **startLLM**(`opts`): [`LLM`](../classes/llm) +> **startLLM**(`opts`): [`LLM`](../interfaces/llm) Start an LLM span as a child of the current Turn. Throws if no Turn is active. -#### Parameters +Defined in: [src/genai/api.ts:77](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L77) + +## Parameters -| Name | Type | -| :------ | :------ | -| `opts` | [`LLMInit`](../interfaces/llminit) | +### opts -#### Returns +[`LLMInit`](../interfaces/llminit) -[`LLM`](../classes/llm) +## Returns -`Example` +[`LLM`](../interfaces/llm) + +## Examples ```ts twoslash // @noErrors weave.startLLM({model: 'gpt-4o-mini', providerName: 'openai'}); ``` -`Example` - ```ts twoslash // @noErrors weave.startLLM({ @@ -37,10 +35,4 @@ weave.startLLM({ systemInstructions: ['You are a helpful weather bot.'], startTime: new Date('2026-05-29T10:00:00.000Z'), }); -``` - -#### Defined in - -[src/genai/api.ts:77](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L77) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/startsession.mdx b/weave/reference/typescript-sdk/functions/startsession.mdx deleted file mode 100644 index 0529b0711b..0000000000 --- a/weave/reference/typescript-sdk/functions/startsession.mdx +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "startSession" -description: "TypeScript SDK reference" ---- - -# startSession - - - **Deprecated.** Use [startConversation](./startconversation) instead. - - -▸ **startSession**(`opts?`): [`Conversation`](../classes/conversation) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `opts` | [`ConversationInit`](../interfaces/conversationinit) | - -#### Returns - -[`Conversation`](../classes/conversation) - -#### Defined in - -[src/genai/api.ts:33](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L33) - -___ diff --git a/weave/reference/typescript-sdk/functions/startsubagent.mdx b/weave/reference/typescript-sdk/functions/startsubagent.mdx index 0f9b7100c3..e15f80cc79 100644 --- a/weave/reference/typescript-sdk/functions/startsubagent.mdx +++ b/weave/reference/typescript-sdk/functions/startsubagent.mdx @@ -3,31 +3,29 @@ title: "startSubagent" description: "TypeScript SDK reference" --- -# startSubagent - -▸ **startSubagent**(`opts`): [`SubAgent`](../classes/subagent) +> **startSubagent**(`opts`): [`SubAgent`](../interfaces/subagent) Start a SubAgent span. Same parent-resolution rules as `startTool`. -#### Parameters +Defined in: [src/genai/api.ts:137](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L137) + +## Parameters -| Name | Type | -| :------ | :------ | -| `opts` | [`SubAgentInit`](../interfaces/subagentinit) | +### opts -#### Returns +[`SubAgentInit`](../interfaces/subagentinit) -[`SubAgent`](../classes/subagent) +## Returns -`Example` +[`SubAgent`](../interfaces/subagent) + +## Examples ```ts twoslash // @noErrors weave.startSubagent({name: 'critic'}); ``` -`Example` - ```ts twoslash // @noErrors weave.startSubagent({ @@ -36,10 +34,4 @@ weave.startSubagent({ systemInstructions: ['Critique the proposed plan.'], startTime: new Date('2026-05-29T10:00:00.000Z'), }); -``` - -#### Defined in - -[src/genai/api.ts:137](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L137) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/starttool.mdx b/weave/reference/typescript-sdk/functions/starttool.mdx index 6a2c0f7f23..9f198f8ea8 100644 --- a/weave/reference/typescript-sdk/functions/starttool.mdx +++ b/weave/reference/typescript-sdk/functions/starttool.mdx @@ -3,9 +3,7 @@ title: "startTool" description: "TypeScript SDK reference" --- -# startTool - -▸ **startTool**(`opts`): [`Tool`](../classes/tool) +> **startTool**(`opts`): [`Tool`](../interfaces/tool) Start a Tool span. Parent resolution (matches the design's "flat by default, hierarchical if you nest"): @@ -14,17 +12,19 @@ default, hierarchical if you nest"): Throws if neither a Turn nor an LLM is active. -#### Parameters +Defined in: [src/genai/api.ts:110](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L110) + +## Parameters -| Name | Type | -| :------ | :------ | -| `opts` | [`ToolInit`](../interfaces/toolinit) | +### opts -#### Returns +[`ToolInit`](../interfaces/toolinit) -[`Tool`](../classes/tool) +## Returns -`Example` +[`Tool`](../interfaces/tool) + +## Examples ```ts twoslash // @noErrors @@ -35,8 +35,6 @@ weave.startTool({ }); ``` -`Example` - ```ts twoslash // @noErrors weave.startTool({ @@ -45,10 +43,4 @@ weave.startTool({ toolCallId: 'call_t1', startTime: new Date('2026-05-29T10:00:00.800Z'), }); -``` - -#### Defined in - -[src/genai/api.ts:110](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L110) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/startturn.mdx b/weave/reference/typescript-sdk/functions/startturn.mdx index 3580846e29..0bb8877ba0 100644 --- a/weave/reference/typescript-sdk/functions/startturn.mdx +++ b/weave/reference/typescript-sdk/functions/startturn.mdx @@ -3,32 +3,30 @@ title: "startTurn" description: "TypeScript SDK reference" --- -# startTurn - -▸ **startTurn**(`opts?`): [`Turn`](../classes/turn) +> **startTurn**(`opts?`): [`Turn`](../interfaces/turn) Start a new Turn. If a Conversation is active, the turn inherits its `conversationId`; otherwise the turn has no conversation id. -#### Parameters +Defined in: [src/genai/api.ts:54](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L54) + +## Parameters -| Name | Type | -| :------ | :------ | -| `opts` | [`TurnInit`](../interfaces/turninit) | +### opts? -#### Returns +[`TurnInit`](../interfaces/turninit) = `{}` -[`Turn`](../classes/turn) +## Returns -`Example` +[`Turn`](../interfaces/turn) + +## Examples ```ts twoslash // @noErrors weave.startTurn(); ``` -`Example` - ```ts twoslash // @noErrors weave.startTurn({ @@ -41,10 +39,4 @@ weave.startTurn({ systemInstructions: ['You are a helpful weather bot.'], startTime: new Date('2026-05-29T10:00:00.000Z'), }); -``` - -#### Defined in - -[src/genai/api.ts:54](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L54) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/weaveaudio.mdx b/weave/reference/typescript-sdk/functions/weaveaudio.mdx index 8ea67fec69..b6a1a7ad14 100644 --- a/weave/reference/typescript-sdk/functions/weaveaudio.mdx +++ b/weave/reference/typescript-sdk/functions/weaveaudio.mdx @@ -3,32 +3,30 @@ title: "weaveAudio" description: "TypeScript SDK reference" --- -# weaveAudio - -▸ **weaveAudio**(`options`): [`WeaveAudio`](../interfaces/weaveaudio) +> **weaveAudio**(`options`): [`WeaveAudio`](../interfaces/weaveaudio) Create a new WeaveAudio object -#### Parameters +Defined in: [src/media.ts:62](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L62) + +## Parameters + +### options + +`WeaveAudioInput` -| Name | Type | Description | -| :------ | :------ | :------ | -| `options` | `WeaveAudioInput` | The options for this media type - data: The raw audio data as a Buffer - audioType: (Optional) The type of audio file, currently only 'wav' is supported | +The options for this media type + - data: The raw audio data as a Buffer + - audioType: (Optional) The type of audio file, currently only 'wav' is supported -#### Returns +## Returns [`WeaveAudio`](../interfaces/weaveaudio) -`Example` +## Example ```ts twoslash // @noErrors const audioBuffer = fs.readFileSync('path/to/audio.wav'); const weaveAudio = weaveAudio({ data: audioBuffer }); -``` - -#### Defined in - -[src/media.ts:62](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L62) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/weaveimage.mdx b/weave/reference/typescript-sdk/functions/weaveimage.mdx index 1ac429f919..54d10eab2b 100644 --- a/weave/reference/typescript-sdk/functions/weaveimage.mdx +++ b/weave/reference/typescript-sdk/functions/weaveimage.mdx @@ -3,32 +3,30 @@ title: "weaveImage" description: "TypeScript SDK reference" --- -# weaveImage - -▸ **weaveImage**(`options`): [`WeaveImage`](../interfaces/weaveimage) +> **weaveImage**(`options`): [`WeaveImage`](../interfaces/weaveimage) Create a new WeaveImage object -#### Parameters +Defined in: [src/media.ts:28](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L28) + +## Parameters + +### options + +`WeaveImageInput` -| Name | Type | Description | -| :------ | :------ | :------ | -| `options` | `WeaveImageInput` | The options for this media type - data: The raw image data as a Buffer - imageType: (Optional) The type of image file, currently only 'png' is supported | +The options for this media type + - data: The raw image data as a Buffer + - imageType: (Optional) The type of image file, currently only 'png' is supported -#### Returns +## Returns [`WeaveImage`](../interfaces/weaveimage) -`Example` +## Example ```ts twoslash // @noErrors const imageBuffer = fs.readFileSync('path/to/image.png'); const weaveImage = weaveImage({ data: imageBuffer }); -``` - -#### Defined in - -[src/media.ts:28](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L28) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/withattributes.mdx b/weave/reference/typescript-sdk/functions/withattributes.mdx index fe213929ee..403992ab32 100644 --- a/weave/reference/typescript-sdk/functions/withattributes.mdx +++ b/weave/reference/typescript-sdk/functions/withattributes.mdx @@ -3,9 +3,7 @@ title: "withAttributes" description: "TypeScript SDK reference" --- -# withAttributes - -▸ **withAttributes**\<`T`\>(`attrs`, `fn`): `Promise`\<`T`\> \| `T` +> **withAttributes**\<`T`\>(`attrs`, `fn`): `T` \| `Promise`\<`T`\> Attach attributes to the current execution context so that any calls created inside `fn` automatically inherit them. Attributes are written to the call @@ -20,25 +18,24 @@ await withAttributes({requestId: 'abc'}, async () => { }); ``` -#### Type parameters +Defined in: [src/clientApi.ts:209](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L209) + +## Type Parameters + +### T -| Name | -| :------ | -| `T` | +`T` -#### Parameters +## Parameters -| Name | Type | -| :------ | :------ | -| `attrs` | `Record`\<`string`, `any`\> | -| `fn` | () => `T` \| `Promise`\<`T`\> | +### attrs -#### Returns +`Record`\<`string`, `any`\> -`Promise`\<`T`\> \| `T` +### fn -#### Defined in +() => `T` \| `Promise`\<`T`\> -[src/clientApi.ts:209](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/clientApi.ts#L209) +## Returns -___ +`T` \| `Promise`\<`T`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/wrapclaudeagentsdk.mdx b/weave/reference/typescript-sdk/functions/wrapclaudeagentsdk.mdx index 6d6311ca7e..1ff12057b4 100644 --- a/weave/reference/typescript-sdk/functions/wrapclaudeagentsdk.mdx +++ b/weave/reference/typescript-sdk/functions/wrapclaudeagentsdk.mdx @@ -3,9 +3,7 @@ title: "wrapClaudeAgentSdk" description: "TypeScript SDK reference" --- -# wrapClaudeAgentSdk - -▸ **wrapClaudeAgentSdk**\<`T`\>(`sdk`): `T` +> **wrapClaudeAgentSdk**\<`T`\>(`sdk`): `T` Manually instrument the `@anthropic-ai/claude-agent-sdk` module. @@ -16,23 +14,25 @@ view of the module whose `query` export is traced; use the returned object rather than the original import (the SDK's `query` is a getter-only export, so the original binding can't be patched in place): -#### Type parameters +Defined in: [src/integrations/claudeAgentSdk.ts:209](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/claudeAgentSdk.ts#L209) + +## Type Parameters -| Name | -| :------ | -| `T` | +### T -#### Parameters +`T` -| Name | Type | -| :------ | :------ | -| `sdk` | `T` | +## Parameters -#### Returns +### sdk `T` -`Example` +## Returns + +`T` + +## Example ```ts twoslash // @noErrors @@ -43,10 +43,4 @@ const { query } = wrapClaudeAgentSdk(claudeAgentSdk); for await (const message of query({ prompt: 'hi' })) { // ...traced } -``` - -#### Defined in - -[src/integrations/claudeAgentSdk.ts:209](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/claudeAgentSdk.ts#L209) - -___ +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/wrapgooglegenai.mdx b/weave/reference/typescript-sdk/functions/wrapgooglegenai.mdx index 343ecc484e..d1c276417e 100644 --- a/weave/reference/typescript-sdk/functions/wrapgooglegenai.mdx +++ b/weave/reference/typescript-sdk/functions/wrapgooglegenai.mdx @@ -3,28 +3,22 @@ title: "wrapGoogleGenAI" description: "TypeScript SDK reference" --- -# wrapGoogleGenAI +> **wrapGoogleGenAI**\<`T`\>(`googleGenAI`): `T` -▸ **wrapGoogleGenAI**\<`T`\>(`googleGenAI`): `T` +Defined in: [src/integrations/googleGenAI.ts:239](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleGenAI.ts#L239) -#### Type parameters +## Type Parameters -| Name | Type | -| :------ | :------ | -| `T` | extends `GoogleGenAIAPI` | +### T -#### Parameters +`T` *extends* `GoogleGenAIAPI` -| Name | Type | -| :------ | :------ | -| `googleGenAI` | `T` | +## Parameters -#### Returns +### googleGenAI `T` -#### Defined in +## Returns -[src/integrations/googleGenAI.ts:239](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/googleGenAI.ts#L239) - -___ +`T` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/functions/wrapopenai.mdx b/weave/reference/typescript-sdk/functions/wrapopenai.mdx index 1e13998641..1311ce40ea 100644 --- a/weave/reference/typescript-sdk/functions/wrapopenai.mdx +++ b/weave/reference/typescript-sdk/functions/wrapopenai.mdx @@ -3,29 +3,29 @@ title: "wrapOpenAI" description: "TypeScript SDK reference" --- -# wrapOpenAI - -▸ **wrapOpenAI**\<`T`\>(`openai`): `T` +> **wrapOpenAI**\<`T`\>(`openai`): `T` Wraps the OpenAI API to enable function tracing for OpenAI calls. -#### Type parameters +Defined in: [src/integrations/openai.ts:723](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.ts#L723) + +## Type Parameters -| Name | Type | -| :------ | :------ | -| `T` | extends `OpenAIAPI` | +### T -#### Parameters +`T` *extends* `OpenAIAPI` -| Name | Type | -| :------ | :------ | -| `openai` | `T` | +## Parameters -#### Returns +### openai `T` -`Example` +## Returns + +`T` + +## Example ```ts twoslash // @noErrors @@ -34,8 +34,4 @@ const result = await openai.chat.completions.create({ model: 'gpt-3.5-turbo', messages: [{ role: 'user', content: 'Hello, world!' }] }); -``` - -#### Defined in - -[src/integrations/openai.ts:723](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/integrations/openai.ts#L723) \ No newline at end of file +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/callschema.mdx b/weave/reference/typescript-sdk/interfaces/callschema.mdx index 2b21a252e8..6618802ea2 100644 --- a/weave/reference/typescript-sdk/interfaces/callschema.mdx +++ b/weave/reference/typescript-sdk/interfaces/callschema.mdx @@ -5,322 +5,247 @@ description: "TypeScript SDK reference" CallSchema -## Table of contents - -### Properties - -- [attributes](./callschema#attributes) -- [deleted\_at](./callschema#deleted_at) -- [display\_name](./callschema#display_name) -- [ended\_at](./callschema#ended_at) -- [exception](./callschema#exception) -- [expire\_at](./callschema#expire_at) -- [id](./callschema#id) -- [inputs](./callschema#inputs) -- [op\_name](./callschema#op_name) -- [output](./callschema#output) -- [parent\_id](./callschema#parent_id) -- [project\_id](./callschema#project_id) -- [started\_at](./callschema#started_at) -- [storage\_size\_bytes](./callschema#storage_size_bytes) -- [summary](./callschema#summary) -- [thread\_id](./callschema#thread_id) -- [total\_storage\_size\_bytes](./callschema#total_storage_size_bytes) -- [trace\_id](./callschema#trace_id) -- [turn\_id](./callschema#turn_id) -- [wb\_run\_id](./callschema#wb_run_id) -- [wb\_run\_step](./callschema#wb_run_step) -- [wb\_run\_step\_end](./callschema#wb_run_step_end) -- [wb\_user\_id](./callschema#wb_user_id) -- [wb\_username](./callschema#wb_username) +Defined in: [src/generated/traceServerApi.ts:1847](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1847) ## Properties ### attributes -• **attributes**: `Record`\<`string`, `any`\> +> **attributes**: `Record`\<`string`, `any`\> Attributes -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1870](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1870) -[src/generated/traceServerApi.ts:1870](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1870) - -___ +*** ### deleted\_at -• `Optional` **deleted\_at**: ``null`` \| `string` +> `optional` **deleted\_at**: `string` \| `null` Deleted At -#### Defined in - -[src/generated/traceServerApi.ts:1891](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1891) +Defined in: [src/generated/traceServerApi.ts:1891](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1891) -___ +*** ### display\_name -• `Optional` **display\_name**: ``null`` \| `string` +> `optional` **display\_name**: `string` \| `null` Display Name -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1855](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1855) -[src/generated/traceServerApi.ts:1855](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1855) - -___ +*** ### ended\_at -• `Optional` **ended\_at**: ``null`` \| `string` +> `optional` **ended\_at**: `string` \| `null` Ended At -#### Defined in - -[src/generated/traceServerApi.ts:1874](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1874) +Defined in: [src/generated/traceServerApi.ts:1874](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1874) -___ +*** ### exception -• `Optional` **exception**: ``null`` \| `string` +> `optional` **exception**: `string` \| `null` Exception -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1876](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1876) -[src/generated/traceServerApi.ts:1876](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1876) - -___ +*** ### expire\_at -• `Optional` **expire\_at**: ``null`` \| `string` +> `optional` **expire\_at**: `string` \| `null` Expire At Expiration timestamp for this call. None = no TTL configured for the project (the row will not be expired). -#### Defined in - -[src/generated/traceServerApi.ts:1896](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1896) +Defined in: [src/generated/traceServerApi.ts:1896](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1896) -___ +*** ### id -• **id**: `string` +> **id**: `string` Id -#### Defined in - -[src/generated/traceServerApi.ts:1849](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1849) +Defined in: [src/generated/traceServerApi.ts:1849](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1849) -___ +*** ### inputs -• **inputs**: `Record`\<`string`, `any`\> +> **inputs**: `Record`\<`string`, `any`\> Inputs -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1872](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1872) -[src/generated/traceServerApi.ts:1872](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1872) - -___ +*** ### op\_name -• **op\_name**: `string` +> **op\_name**: `string` Op Name -#### Defined in - -[src/generated/traceServerApi.ts:1853](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1853) +Defined in: [src/generated/traceServerApi.ts:1853](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1853) -___ +*** ### output -• `Optional` **output**: ``null`` +> `optional` **output**: `null` Output -#### Defined in - -[src/generated/traceServerApi.ts:1878](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1878) +Defined in: [src/generated/traceServerApi.ts:1878](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1878) -___ +*** ### parent\_id -• `Optional` **parent\_id**: ``null`` \| `string` +> `optional` **parent\_id**: `string` \| `null` Parent Id -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1859](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1859) -[src/generated/traceServerApi.ts:1859](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1859) - -___ +*** ### project\_id -• **project\_id**: `string` +> **project\_id**: `string` Project Id -#### Defined in - -[src/generated/traceServerApi.ts:1851](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1851) +Defined in: [src/generated/traceServerApi.ts:1851](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1851) -___ +*** ### started\_at -• **started\_at**: `string` +> **started\_at**: `string` Started At -`Format` - -date-time +Defined in: [src/generated/traceServerApi.ts:1868](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1868) -#### Defined in +#### Format -[src/generated/traceServerApi.ts:1868](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1868) +date-time -___ +*** ### storage\_size\_bytes -• `Optional` **storage\_size\_bytes**: ``null`` \| `number` +> `optional` **storage\_size\_bytes**: `number` \| `null` Storage Size Bytes -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1898](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1898) -[src/generated/traceServerApi.ts:1898](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1898) - -___ +*** ### summary -• `Optional` **summary**: `Record`\<`string`, `any`\> - -#### Defined in +> `optional` **summary**: `Record`\<`string`, `any`\> -[src/generated/traceServerApi.ts:1879](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1879) +Defined in: [src/generated/traceServerApi.ts:1879](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1879) -___ +*** ### thread\_id -• `Optional` **thread\_id**: ``null`` \| `string` +> `optional` **thread\_id**: `string` \| `null` Thread Id -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1861](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1861) -[src/generated/traceServerApi.ts:1861](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1861) - -___ +*** ### total\_storage\_size\_bytes -• `Optional` **total\_storage\_size\_bytes**: ``null`` \| `number` +> `optional` **total\_storage\_size\_bytes**: `number` \| `null` Total Storage Size Bytes -#### Defined in - -[src/generated/traceServerApi.ts:1900](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1900) +Defined in: [src/generated/traceServerApi.ts:1900](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1900) -___ +*** ### trace\_id -• **trace\_id**: `string` +> **trace\_id**: `string` Trace Id -#### Defined in - -[src/generated/traceServerApi.ts:1857](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1857) +Defined in: [src/generated/traceServerApi.ts:1857](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1857) -___ +*** ### turn\_id -• `Optional` **turn\_id**: ``null`` \| `string` +> `optional` **turn\_id**: `string` \| `null` Turn Id -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1863](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1863) -[src/generated/traceServerApi.ts:1863](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1863) - -___ +*** ### wb\_run\_id -• `Optional` **wb\_run\_id**: ``null`` \| `string` +> `optional` **wb\_run\_id**: `string` \| `null` Wb Run Id -#### Defined in - -[src/generated/traceServerApi.ts:1885](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1885) +Defined in: [src/generated/traceServerApi.ts:1885](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1885) -___ +*** ### wb\_run\_step -• `Optional` **wb\_run\_step**: ``null`` \| `number` +> `optional` **wb\_run\_step**: `number` \| `null` Wb Run Step -#### Defined in - -[src/generated/traceServerApi.ts:1887](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1887) +Defined in: [src/generated/traceServerApi.ts:1887](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1887) -___ +*** ### wb\_run\_step\_end -• `Optional` **wb\_run\_step\_end**: ``null`` \| `number` +> `optional` **wb\_run\_step\_end**: `number` \| `null` Wb Run Step End -#### Defined in +Defined in: [src/generated/traceServerApi.ts:1889](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1889) -[src/generated/traceServerApi.ts:1889](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1889) - -___ +*** ### wb\_user\_id -• `Optional` **wb\_user\_id**: ``null`` \| `string` +> `optional` **wb\_user\_id**: `string` \| `null` Wb User Id -#### Defined in - -[src/generated/traceServerApi.ts:1881](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1881) +Defined in: [src/generated/traceServerApi.ts:1881](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1881) -___ +*** ### wb\_username -• `Optional` **wb\_username**: ``null`` \| `string` +> `optional` **wb\_username**: `string` \| `null` Wb Username -#### Defined in - -[src/generated/traceServerApi.ts:1883](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1883) \ No newline at end of file +Defined in: [src/generated/traceServerApi.ts:1883](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L1883) diff --git a/weave/reference/typescript-sdk/interfaces/callsfilter.mdx b/weave/reference/typescript-sdk/interfaces/callsfilter.mdx index eb23c07fd5..45aaa218cf 100644 --- a/weave/reference/typescript-sdk/interfaces/callsfilter.mdx +++ b/weave/reference/typescript-sdk/interfaces/callsfilter.mdx @@ -5,150 +5,114 @@ description: "TypeScript SDK reference" CallsFilter -## Table of contents - -### Properties - -- [call\_ids](./callsfilter#call_ids) -- [input\_refs](./callsfilter#input_refs) -- [op\_names](./callsfilter#op_names) -- [output\_refs](./callsfilter#output_refs) -- [parent\_ids](./callsfilter#parent_ids) -- [thread\_ids](./callsfilter#thread_ids) -- [trace\_ids](./callsfilter#trace_ids) -- [trace\_roots\_only](./callsfilter#trace_roots_only) -- [turn\_ids](./callsfilter#turn_ids) -- [wb\_run\_ids](./callsfilter#wb_run_ids) -- [wb\_user\_ids](./callsfilter#wb_user_ids) +Defined in: [src/generated/traceServerApi.ts:2040](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2040) ## Properties ### call\_ids -• `Optional` **call\_ids**: ``null`` \| `string`[] +> `optional` **call\_ids**: `string`[] \| `null` Call Ids -#### Defined in +Defined in: [src/generated/traceServerApi.ts:2052](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2052) -[src/generated/traceServerApi.ts:2052](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2052) - -___ +*** ### input\_refs -• `Optional` **input\_refs**: ``null`` \| `string`[] +> `optional` **input\_refs**: `string`[] \| `null` Input Refs -#### Defined in - -[src/generated/traceServerApi.ts:2044](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2044) +Defined in: [src/generated/traceServerApi.ts:2044](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2044) -___ +*** ### op\_names -• `Optional` **op\_names**: ``null`` \| `string`[] +> `optional` **op\_names**: `string`[] \| `null` Op Names -#### Defined in - -[src/generated/traceServerApi.ts:2042](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2042) +Defined in: [src/generated/traceServerApi.ts:2042](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2042) -___ +*** ### output\_refs -• `Optional` **output\_refs**: ``null`` \| `string`[] +> `optional` **output\_refs**: `string`[] \| `null` Output Refs -#### Defined in +Defined in: [src/generated/traceServerApi.ts:2046](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2046) -[src/generated/traceServerApi.ts:2046](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2046) - -___ +*** ### parent\_ids -• `Optional` **parent\_ids**: ``null`` \| `string`[] +> `optional` **parent\_ids**: `string`[] \| `null` Parent Ids -#### Defined in - -[src/generated/traceServerApi.ts:2048](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2048) +Defined in: [src/generated/traceServerApi.ts:2048](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2048) -___ +*** ### thread\_ids -• `Optional` **thread\_ids**: ``null`` \| `string`[] +> `optional` **thread\_ids**: `string`[] \| `null` Thread Ids -#### Defined in - -[src/generated/traceServerApi.ts:2054](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2054) +Defined in: [src/generated/traceServerApi.ts:2054](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2054) -___ +*** ### trace\_ids -• `Optional` **trace\_ids**: ``null`` \| `string`[] +> `optional` **trace\_ids**: `string`[] \| `null` Trace Ids -#### Defined in +Defined in: [src/generated/traceServerApi.ts:2050](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2050) -[src/generated/traceServerApi.ts:2050](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2050) - -___ +*** ### trace\_roots\_only -• `Optional` **trace\_roots\_only**: ``null`` \| `boolean` +> `optional` **trace\_roots\_only**: `boolean` \| `null` Trace Roots Only -#### Defined in - -[src/generated/traceServerApi.ts:2058](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2058) +Defined in: [src/generated/traceServerApi.ts:2058](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2058) -___ +*** ### turn\_ids -• `Optional` **turn\_ids**: ``null`` \| `string`[] +> `optional` **turn\_ids**: `string`[] \| `null` Turn Ids -#### Defined in - -[src/generated/traceServerApi.ts:2056](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2056) +Defined in: [src/generated/traceServerApi.ts:2056](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2056) -___ +*** ### wb\_run\_ids -• `Optional` **wb\_run\_ids**: ``null`` \| `string`[] +> `optional` **wb\_run\_ids**: `string`[] \| `null` Wb Run Ids -#### Defined in +Defined in: [src/generated/traceServerApi.ts:2062](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2062) -[src/generated/traceServerApi.ts:2062](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2062) - -___ +*** ### wb\_user\_ids -• `Optional` **wb\_user\_ids**: ``null`` \| `string`[] +> `optional` **wb\_user\_ids**: `string`[] \| `null` Wb User Ids -#### Defined in - -[src/generated/traceServerApi.ts:2060](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2060) \ No newline at end of file +Defined in: [src/generated/traceServerApi.ts:2060](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L2060) diff --git a/weave/reference/typescript-sdk/interfaces/conversation.mdx b/weave/reference/typescript-sdk/interfaces/conversation.mdx new file mode 100644 index 0000000000..e3b8cc43b0 --- /dev/null +++ b/weave/reference/typescript-sdk/interfaces/conversation.mdx @@ -0,0 +1,145 @@ +--- +title: "Conversation" +description: "TypeScript SDK reference" +--- + +A Conversation groups Turns under a single `gen_ai.conversation.id`. It is +not itself an OTel span — children stamp the conversation id onto theirs. + +Defined in: [src/genai/conversation.ts:72](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L72) + +## Accessors + +### agentName + +#### Get Signature + +> **get** **agentName**(): `string` + +Defined in: [src/genai/conversation.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L94) + +##### Returns + +`string` + +*** + +### attributes + +#### Get Signature + +> **get** **attributes**(): `Attributes` + +Defined in: [src/genai/conversation.ts:106](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L106) + +##### Returns + +`Attributes` + +*** + +### conversationId + +#### Get Signature + +> **get** **conversationId**(): `string` + +Defined in: [src/genai/conversation.ts:102](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L102) + +##### Returns + +`string` + +*** + +### model + +#### Get Signature + +> **get** **model**(): `string` + +Defined in: [src/genai/conversation.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L98) + +##### Returns + +`string` + +*** + +### sessionId + + + **Deprecated.** Use [Conversation.conversationId](#conversationid) instead. + + +#### Get Signature + +> **get** **sessionId**(): `string` + +Defined in: [src/genai/conversation.ts:111](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L111) + +##### Returns + +`string` + +## Methods + +### end() + +> **end**(`opts?`): `void` + +Defined in: [src/genai/conversation.ts:168](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L168) + +#### Parameters + +##### opts? + +`SpanEndOptions` + +#### Returns + +`void` + +*** + +### startTurn() + +> **startTurn**(`opts?`): [`Turn`](./turn) + +Start a new `Turn` under this `Conversation`. The turn inherits the +conversation's `conversationId`; `agentName`, `agentId`, `agentDescription`, +`agentVersion` and `model` fall back to the conversation's values when not +provided on `opts`. + +Defined in: [src/genai/conversation.ts:156](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L156) + +#### Parameters + +##### opts? + +[`TurnInit`](./turninit) = `{}` + +#### Returns + +[`Turn`](./turn) + +#### Examples + +```ts twoslash +// @noErrors +const turn = conversation.startTurn(); +``` + +```ts twoslash +// @noErrors +const turn = conversation.startTurn({ + model: 'gpt-4o', + agentName: 'research-bot', + agentId: 'research-bot-prod', + agentDescription: 'Looks up facts on Wikipedia.', + agentVersion: '1.4.2', + userMessage: 'What is the weather in Tokyo?', + systemInstructions: ['You are a helpful weather bot.'], + startTime: new Date('2026-05-29T10:00:00.000Z'), +}); +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/conversationinit.mdx b/weave/reference/typescript-sdk/interfaces/conversationinit.mdx index 0721d269a6..51d6e48093 100644 --- a/weave/reference/typescript-sdk/interfaces/conversationinit.mdx +++ b/weave/reference/typescript-sdk/interfaces/conversationinit.mdx @@ -3,124 +3,97 @@ title: "ConversationInit" description: "TypeScript SDK reference" --- -## Table of contents - -### Properties - -- [agentDescription](./conversationinit#agentdescription) -- [agentId](./conversationinit#agentid) -- [agentName](./conversationinit#agentname) -- [agentVersion](./conversationinit#agentversion) -- [attributes](./conversationinit#attributes) -- [conversationId](./conversationinit#conversationid) -- [model](./conversationinit#model) -- [sessionId](./conversationinit#sessionid) +Defined in: [src/genai/conversation.ts:8](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L8) ## Properties ### agentDescription -• `Optional` **agentDescription**: `string` +> `optional` **agentDescription**: `string` Human-readable agent description. Propagated as the default `agentDescription` to every `Turn` created via `startTurn()` unless the turn sets its own; emitted on each turn's `invoke_agent` span as `gen_ai.agent.description`. -#### Defined in - -[src/genai/conversation.ts:31](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L31) +Defined in: [src/genai/conversation.ts:31](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L31) -___ +*** ### agentId -• `Optional` **agentId**: `string` +> `optional` **agentId**: `string` Stable agent identifier. Propagated as the default `agentId` to every `Turn` created via `startTurn()` unless the turn sets its own; emitted on each turn's `invoke_agent` span as `gen_ai.agent.id`. -#### Defined in +Defined in: [src/genai/conversation.ts:16](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L16) -[src/genai/conversation.ts:16](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L16) - -___ +*** ### agentName -• `Optional` **agentName**: `string` +> `optional` **agentName**: `string` Agent name. Propagated as the default `agentName` to every `Turn` created via `startTurn()` unless the turn sets its own; emitted on each turn's `invoke_agent` span as `gen_ai.agent.name`. -#### Defined in - -[src/genai/conversation.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L23) +Defined in: [src/genai/conversation.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L23) -___ +*** ### agentVersion -• `Optional` **agentVersion**: `string` +> `optional` **agentVersion**: `string` Agent version string. Propagated as the default `agentVersion` to every `Turn` created via `startTurn()` unless the turn sets its own; emitted on each turn's `invoke_agent` span as `gen_ai.agent.version`. -#### Defined in +Defined in: [src/genai/conversation.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L38) -[src/genai/conversation.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L38) - -___ +*** ### attributes -• `Optional` **attributes**: `Attributes` +> `optional` **attributes**: `Attributes` Custom attributes stamped on every span the conversation emits. A key here that collides with a span's own `gen_ai.*` / `weave.*` attribute is unsupported; the span's value wins. -#### Defined in - -[src/genai/conversation.ts:52](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L52) +Defined in: [src/genai/conversation.ts:52](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L52) -___ +*** ### conversationId -• `Optional` **conversationId**: `string` +> `optional` **conversationId**: `string` Conversation ID propagated to every span under this conversation as `gen_ai.conversation.id`. Auto-generated if omitted. -#### Defined in - -[src/genai/conversation.ts:44](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L44) +Defined in: [src/genai/conversation.ts:44](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L44) -___ +*** ### model -• `Optional` **model**: `string` +> `optional` **model**: `string` -#### Defined in +Defined in: [src/genai/conversation.ts:9](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L9) -[src/genai/conversation.ts:9](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L9) +*** -___ - -### sessionId +### ~~sessionId~~ - **Deprecated.** Use [ConversationInit.conversationId](./conversationinit#conversationid) instead. + **Deprecated.** Use [ConversationInit.conversationId](#conversationid) instead. -• `Optional` **sessionId**: `string` - -#### Defined in +> `optional` **sessionId**: `string` -[src/genai/conversation.ts:55](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L55) \ No newline at end of file +Defined in: [src/genai/conversation.ts:55](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L55) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/getagentsoptions.mdx b/weave/reference/typescript-sdk/interfaces/getagentsoptions.mdx index e496db7282..453065b60b 100644 --- a/weave/reference/typescript-sdk/interfaces/getagentsoptions.mdx +++ b/weave/reference/typescript-sdk/interfaces/getagentsoptions.mdx @@ -3,53 +3,38 @@ title: "GetAgentsOptions" description: "TypeScript SDK reference" --- -Options for [WeaveClient.getAgents](../classes/weaveclient#getagents). +Options for [WeaveClient.getAgents](./weaveclient#getagents). -## Table of contents - -### Properties - -- [agentName](./getagentsoptions#agentname) -- [limit](./getagentsoptions#limit) -- [offset](./getagentsoptions#offset) -- [sortBy](./getagentsoptions#sortby) +Defined in: [src/weaveClient.ts:115](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L115) ## Properties ### agentName -• `Optional` **agentName**: `string` - -#### Defined in +> `optional` **agentName**: `string` -[src/weaveClient.ts:116](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L116) +Defined in: [src/weaveClient.ts:116](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L116) -___ +*** ### limit -• `Optional` **limit**: `number` +> `optional` **limit**: `number` -#### Defined in +Defined in: [src/weaveClient.ts:117](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L117) -[src/weaveClient.ts:117](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L117) - -___ +*** ### offset -• `Optional` **offset**: `number` - -#### Defined in +> `optional` **offset**: `number` -[src/weaveClient.ts:118](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L118) +Defined in: [src/weaveClient.ts:118](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L118) -___ +*** ### sortBy -• `Optional` **sortBy**: [`SortBy`](./sortby)[] - -#### Defined in +> `optional` **sortBy**: [`SortBy`](./sortby)[] -[src/weaveClient.ts:119](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L119) \ No newline at end of file +Defined in: [src/weaveClient.ts:119](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L119) diff --git a/weave/reference/typescript-sdk/interfaces/getagentspansoptions.mdx b/weave/reference/typescript-sdk/interfaces/getagentspansoptions.mdx index c2ef056d33..4b3830df36 100644 --- a/weave/reference/typescript-sdk/interfaces/getagentspansoptions.mdx +++ b/weave/reference/typescript-sdk/interfaces/getagentspansoptions.mdx @@ -3,92 +3,74 @@ title: "GetAgentSpansOptions" description: "TypeScript SDK reference" --- -Options for [WeaveClient.getAgentSpans](../classes/weaveclient#getagentspans). +Options for [WeaveClient.getAgentSpans](./weaveclient#getagentspans). -## Table of contents - -### Properties - -- [agentName](./getagentspansoptions#agentname) -- [limit](./getagentspansoptions#limit) -- [offset](./getagentspansoptions#offset) -- [query](./getagentspansoptions#query) -- [sortBy](./getagentspansoptions#sortby) +Defined in: [src/weaveClient.ts:160](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L160) ## Properties ### agentName -• `Optional` **agentName**: `string` - -#### Defined in +> `optional` **agentName**: `string` -[src/weaveClient.ts:161](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L161) +Defined in: [src/weaveClient.ts:161](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L161) -___ +*** ### limit -• `Optional` **limit**: `number` +> `optional` **limit**: `number` -`Min` +Defined in: [src/weaveClient.ts:171](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L171) + +#### Min 0 -`Max` +#### Max 10000 -`Default` +#### Default ```ts twoslash // @noErrors 100 ``` -#### Defined in - -[src/weaveClient.ts:171](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L171) - -___ +*** ### offset -• `Optional` **offset**: `number` +> `optional` **offset**: `number` -`Min` +Defined in: [src/weaveClient.ts:176](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L176) + +#### Min 0 -`Default` +#### Default ```ts twoslash // @noErrors 0 ``` -#### Defined in - -[src/weaveClient.ts:176](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L176) - -___ +*** ### query -• `Optional` **query**: ``null`` \| [`Query`](./query) +> `optional` **query**: [`Query`](./query) \| `null` Mongo-style filter on the spans. -#### Defined in +Defined in: [src/weaveClient.ts:165](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L165) -[src/weaveClient.ts:165](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L165) - -___ +*** ### sortBy -• `Optional` **sortBy**: [`SortBy`](./sortby)[] - -#### Defined in +> `optional` **sortBy**: [`SortBy`](./sortby)[] -[src/weaveClient.ts:177](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L177) \ No newline at end of file +Defined in: [src/weaveClient.ts:177](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L177) diff --git a/weave/reference/typescript-sdk/interfaces/getagentturnoptions.mdx b/weave/reference/typescript-sdk/interfaces/getagentturnoptions.mdx index 68600a6599..d638b60d1f 100644 --- a/weave/reference/typescript-sdk/interfaces/getagentturnoptions.mdx +++ b/weave/reference/typescript-sdk/interfaces/getagentturnoptions.mdx @@ -3,31 +3,22 @@ title: "GetAgentTurnOptions" description: "TypeScript SDK reference" --- -Options for [WeaveClient.getAgentTurn](../classes/weaveclient#getagentturn). +Options for [WeaveClient.getAgentTurn](./weaveclient#getagentturn). -## Table of contents - -### Properties - -- [includeFeedback](./getagentturnoptions#includefeedback) -- [traceId](./getagentturnoptions#traceid) +Defined in: [src/weaveClient.ts:220](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L220) ## Properties ### includeFeedback -• `Optional` **includeFeedback**: `boolean` +> `optional` **includeFeedback**: `boolean` -#### Defined in +Defined in: [src/weaveClient.ts:222](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L222) -[src/weaveClient.ts:222](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L222) - -___ +*** ### traceId -• **traceId**: `string` - -#### Defined in +> **traceId**: `string` -[src/weaveClient.ts:221](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L221) \ No newline at end of file +Defined in: [src/weaveClient.ts:221](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L221) diff --git a/weave/reference/typescript-sdk/interfaces/getagentturnsoptions.mdx b/weave/reference/typescript-sdk/interfaces/getagentturnsoptions.mdx index 0763b362f4..9c753a2c6c 100644 --- a/weave/reference/typescript-sdk/interfaces/getagentturnsoptions.mdx +++ b/weave/reference/typescript-sdk/interfaces/getagentturnsoptions.mdx @@ -3,79 +3,64 @@ title: "GetAgentTurnsOptions" description: "TypeScript SDK reference" --- -Options for [WeaveClient.getAgentTurns](../classes/weaveclient#getagentturns). +Options for [WeaveClient.getAgentTurns](./weaveclient#getagentturns). -## Table of contents - -### Properties - -- [conversationId](./getagentturnsoptions#conversationid) -- [includeFeedback](./getagentturnsoptions#includefeedback) -- [limit](./getagentturnsoptions#limit) -- [offset](./getagentturnsoptions#offset) +Defined in: [src/weaveClient.ts:233](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L233) ## Properties ### conversationId -• **conversationId**: `string` - -#### Defined in +> **conversationId**: `string` -[src/weaveClient.ts:234](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L234) +Defined in: [src/weaveClient.ts:234](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L234) -___ +*** ### includeFeedback -• `Optional` **includeFeedback**: `boolean` +> `optional` **includeFeedback**: `boolean` -#### Defined in +Defined in: [src/weaveClient.ts:246](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L246) -[src/weaveClient.ts:246](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L246) - -___ +*** ### limit -• `Optional` **limit**: `number` +> `optional` **limit**: `number` + +Defined in: [src/weaveClient.ts:240](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L240) -`Min` +#### Min 0 -`Max` +#### Max 50 -`Default` +#### Default ```ts twoslash // @noErrors 50 ``` -#### Defined in - -[src/weaveClient.ts:240](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L240) - -___ +*** ### offset -• `Optional` **offset**: `number` +> `optional` **offset**: `number` + +Defined in: [src/weaveClient.ts:245](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L245) -`Min` +#### Min 0 -`Default` +#### Default ```ts twoslash // @noErrors 0 -``` - -#### Defined in - -[src/weaveClient.ts:245](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L245) \ No newline at end of file +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/getagentversionsoptions.mdx b/weave/reference/typescript-sdk/interfaces/getagentversionsoptions.mdx index 761d8b4a00..97328a34ff 100644 --- a/weave/reference/typescript-sdk/interfaces/getagentversionsoptions.mdx +++ b/weave/reference/typescript-sdk/interfaces/getagentversionsoptions.mdx @@ -3,79 +3,64 @@ title: "GetAgentVersionsOptions" description: "TypeScript SDK reference" --- -Options for [WeaveClient.getAgentVersions](../classes/weaveclient#getagentversions). +Options for [WeaveClient.getAgentVersions](./weaveclient#getagentversions). -## Table of contents - -### Properties - -- [agentName](./getagentversionsoptions#agentname) -- [limit](./getagentversionsoptions#limit) -- [offset](./getagentversionsoptions#offset) -- [sortBy](./getagentversionsoptions#sortby) +Defined in: [src/weaveClient.ts:133](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L133) ## Properties ### agentName -• **agentName**: `string` - -#### Defined in +> **agentName**: `string` -[src/weaveClient.ts:134](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L134) +Defined in: [src/weaveClient.ts:134](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L134) -___ +*** ### limit -• `Optional` **limit**: `number` +> `optional` **limit**: `number` -`Min` +Defined in: [src/weaveClient.ts:140](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L140) + +#### Min 0 -`Max` +#### Max 10000 -`Default` +#### Default ```ts twoslash // @noErrors 100 ``` -#### Defined in - -[src/weaveClient.ts:140](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L140) - -___ +*** ### offset -• `Optional` **offset**: `number` +> `optional` **offset**: `number` + +Defined in: [src/weaveClient.ts:145](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L145) -`Min` +#### Min 0 -`Default` +#### Default ```ts twoslash // @noErrors 0 ``` -#### Defined in - -[src/weaveClient.ts:145](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L145) - -___ +*** ### sortBy -• `Optional` **sortBy**: [`SortBy`](./sortby)[] - -#### Defined in +> `optional` **sortBy**: [`SortBy`](./sortby)[] -[src/weaveClient.ts:146](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L146) \ No newline at end of file +Defined in: [src/weaveClient.ts:146](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L146) diff --git a/weave/reference/typescript-sdk/interfaces/getcallsoptions.mdx b/weave/reference/typescript-sdk/interfaces/getcallsoptions.mdx index b052bf7dea..3735c1e7da 100644 --- a/weave/reference/typescript-sdk/interfaces/getcallsoptions.mdx +++ b/weave/reference/typescript-sdk/interfaces/getcallsoptions.mdx @@ -3,106 +3,76 @@ title: "GetCallsOptions" description: "TypeScript SDK reference" --- -## Table of contents - -### Properties - -- [columns](./getcallsoptions#columns) -- [expandColumns](./getcallsoptions#expandcolumns) -- [filter](./getcallsoptions#filter) -- [includeCosts](./getcallsoptions#includecosts) -- [includeFeedback](./getcallsoptions#includefeedback) -- [limit](./getcallsoptions#limit) -- [offset](./getcallsoptions#offset) -- [query](./getcallsoptions#query) -- [sortBy](./getcallsoptions#sortby) +Defined in: [src/weaveClient.ts:93](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L93) ## Properties ### columns -• `Optional` **columns**: `string`[] - -#### Defined in +> `optional` **columns**: `string`[] -[src/weaveClient.ts:101](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L101) +Defined in: [src/weaveClient.ts:101](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L101) -___ +*** ### expandColumns -• `Optional` **expandColumns**: `string`[] +> `optional` **expandColumns**: `string`[] -#### Defined in +Defined in: [src/weaveClient.ts:102](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L102) -[src/weaveClient.ts:102](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L102) - -___ +*** ### filter -• `Optional` **filter**: [`CallsFilter`](./callsfilter) - -#### Defined in +> `optional` **filter**: [`CallsFilter`](./callsfilter) -[src/weaveClient.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L94) +Defined in: [src/weaveClient.ts:94](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L94) -___ +*** ### includeCosts -• `Optional` **includeCosts**: `boolean` - -#### Defined in +> `optional` **includeCosts**: `boolean` -[src/weaveClient.ts:96](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L96) +Defined in: [src/weaveClient.ts:96](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L96) -___ +*** ### includeFeedback -• `Optional` **includeFeedback**: `boolean` +> `optional` **includeFeedback**: `boolean` -#### Defined in +Defined in: [src/weaveClient.ts:97](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L97) -[src/weaveClient.ts:97](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L97) - -___ +*** ### limit -• `Optional` **limit**: `number` - -#### Defined in +> `optional` **limit**: `number` -[src/weaveClient.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L98) +Defined in: [src/weaveClient.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L98) -___ +*** ### offset -• `Optional` **offset**: `number` - -#### Defined in +> `optional` **offset**: `number` -[src/weaveClient.ts:99](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L99) +Defined in: [src/weaveClient.ts:99](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L99) -___ +*** ### query -• `Optional` **query**: [`Query`](./query) +> `optional` **query**: [`Query`](./query) -#### Defined in +Defined in: [src/weaveClient.ts:95](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L95) -[src/weaveClient.ts:95](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L95) - -___ +*** ### sortBy -• `Optional` **sortBy**: [`SortBy`](./sortby)[] - -#### Defined in +> `optional` **sortBy**: [`SortBy`](./sortby)[] -[src/weaveClient.ts:100](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L100) \ No newline at end of file +Defined in: [src/weaveClient.ts:100](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L100) diff --git a/weave/reference/typescript-sdk/interfaces/httpresponse.mdx b/weave/reference/typescript-sdk/interfaces/httpresponse.mdx index 49844c25b3..b17e2f853b 100644 --- a/weave/reference/typescript-sdk/interfaces/httpresponse.mdx +++ b/weave/reference/typescript-sdk/interfaces/httpresponse.mdx @@ -3,102 +3,73 @@ title: "HttpResponse" description: "TypeScript SDK reference" --- -## Type parameters +Defined in: [src/generated/traceServerApi.ts:5989](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5989) -| Name | Type | -| :------ | :------ | -| `D` | extends `unknown` | -| `E` | extends `unknown` = `unknown` | - -## Hierarchy +## Extends - `Response` - ↳ `HttpResponse` - -## Table of contents +## Type Parameters -### Properties +### D -- [body](./httpresponse#body) -- [bodyUsed](./httpresponse#bodyused) -- [data](./httpresponse#data) -- [error](./httpresponse#error) -- [headers](./httpresponse#headers) -- [ok](./httpresponse#ok) -- [redirected](./httpresponse#redirected) -- [status](./httpresponse#status) -- [statusText](./httpresponse#statustext) -- [type](./httpresponse#type) -- [url](./httpresponse#url) +`D` *extends* `unknown` -### Methods +### E -- [arrayBuffer](./httpresponse#arraybuffer) -- [blob](./httpresponse#blob) -- [bytes](./httpresponse#bytes) -- [clone](./httpresponse#clone) -- [formData](./httpresponse#formdata) -- [json](./httpresponse#json) -- [text](./httpresponse#text) +`E` *extends* `unknown` = `unknown` ## Properties ### body -• `Readonly` **body**: ``null`` \| `ReadableStream`\<`Uint8Array`\<`ArrayBuffer`\>\> +> `readonly` **body**: `ReadableStream`\<`Uint8Array`\<`ArrayBuffer`\>\> \| `null` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4468 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/body) #### Inherited from -Response.body - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:4468 +`Response.body` -___ +*** ### bodyUsed -• `Readonly` **bodyUsed**: `boolean` +> `readonly` **bodyUsed**: `boolean` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4470 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bodyUsed) #### Inherited from -Response.bodyUsed - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:4470 +`Response.bodyUsed` -___ +*** ### data -• **data**: `D` +> **data**: `D` -#### Defined in +Defined in: [src/generated/traceServerApi.ts:5991](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5991) -[src/generated/traceServerApi.ts:5991](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5991) - -___ +*** ### error -• **error**: `E` - -#### Defined in +> **error**: `E` -[src/generated/traceServerApi.ts:5992](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5992) +Defined in: [src/generated/traceServerApi.ts:5992](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5992) -___ +*** ### headers -• `Readonly` **headers**: `Headers` +> `readonly` **headers**: `Headers` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26322 The `headers` read-only property of the with the response. @@ -106,17 +77,15 @@ The `headers` read-only property of the with the response. #### Inherited from -Response.headers - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:26322 +`Response.headers` -___ +*** ### ok -• `Readonly` **ok**: `boolean` +> `readonly` **ok**: `boolean` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26328 The `ok` read-only property of the Response interface contains a Boolean stating whether the response was successful (status in the range 200-299) or not. @@ -124,17 +93,15 @@ The `ok` read-only property of the Response interface contains a Boolean stating #### Inherited from -Response.ok - -#### Defined in +`Response.ok` -node_modules/typescript/lib/lib.dom.d.ts:26328 - -___ +*** ### redirected -• `Readonly` **redirected**: `boolean` +> `readonly` **redirected**: `boolean` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26334 The `redirected` read-only property of the Response interface indicates whether or not the response is the result of a request you made which was redirected. @@ -142,17 +109,15 @@ The `redirected` read-only property of the Response interface indicates whether #### Inherited from -Response.redirected - -#### Defined in +`Response.redirected` -node_modules/typescript/lib/lib.dom.d.ts:26334 - -___ +*** ### status -• `Readonly` **status**: `number` +> `readonly` **status**: `number` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26340 The `status` read-only property of the Response interface contains the HTTP status codes of the response. @@ -160,17 +125,15 @@ The `status` read-only property of the Response interface contains the HTTP stat #### Inherited from -Response.status +`Response.status` -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:26340 - -___ +*** ### statusText -• `Readonly` **statusText**: `string` +> `readonly` **statusText**: `string` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26346 The `statusText` read-only property of the Response interface contains the status message corresponding to the HTTP status code in Response.status. @@ -178,17 +141,15 @@ The `statusText` read-only property of the Response interface contains the statu #### Inherited from -Response.statusText - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:26346 +`Response.statusText` -___ +*** ### type -• `Readonly` **type**: `ResponseType` +> `readonly` **type**: `ResponseType` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26352 The `type` read-only property of the Response interface contains the type of the response. @@ -196,17 +157,15 @@ The `type` read-only property of the Response interface contains the type of the #### Inherited from -Response.type - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:26352 +`Response.type` -___ +*** ### url -• `Readonly` **url**: `string` +> `readonly` **url**: `string` + +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26358 The `url` read-only property of the Response interface contains the URL of the response. @@ -214,17 +173,15 @@ The `url` read-only property of the Response interface contains the URL of the r #### Inherited from -Response.url - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:26358 +`Response.url` ## Methods -### arrayBuffer +### arrayBuffer() + +> **arrayBuffer**(): `Promise`\<`ArrayBuffer`\> -▸ **arrayBuffer**(): `Promise`\<`ArrayBuffer`\> +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4472 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/arrayBuffer) @@ -234,17 +191,15 @@ node_modules/typescript/lib/lib.dom.d.ts:26358 #### Inherited from -Response.arrayBuffer - -#### Defined in +`Response.arrayBuffer` -node_modules/typescript/lib/lib.dom.d.ts:4472 +*** -___ +### blob() -### blob +> **blob**(): `Promise`\<`Blob`\> -▸ **blob**(): `Promise`\<`Blob`\> +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4474 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/blob) @@ -254,17 +209,15 @@ ___ #### Inherited from -Response.blob +`Response.blob` -#### Defined in +*** -node_modules/typescript/lib/lib.dom.d.ts:4474 +### bytes() -___ +> **bytes**(): `Promise`\<`Uint8Array`\<`ArrayBuffer`\>\> -### bytes - -▸ **bytes**(): `Promise`\<`Uint8Array`\<`ArrayBuffer`\>\> +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4476 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/bytes) @@ -274,17 +227,15 @@ ___ #### Inherited from -Response.bytes - -#### Defined in +`Response.bytes` -node_modules/typescript/lib/lib.dom.d.ts:4476 +*** -___ +### clone() -### clone +> **clone**(): `Response` -▸ **clone**(): `Response` +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:26364 The `clone()` method of the Response interface creates a clone of a response object, identical in every way, but stored in a different variable. @@ -296,17 +247,15 @@ The `clone()` method of the Response interface creates a clone of a response obj #### Inherited from -Response.clone +`Response.clone` -#### Defined in +*** -node_modules/typescript/lib/lib.dom.d.ts:26364 +### formData() -___ +> **formData**(): `Promise`\<`FormData`\> -### formData - -▸ **formData**(): `Promise`\<`FormData`\> +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4478 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/formData) @@ -316,17 +265,15 @@ ___ #### Inherited from -Response.formData - -#### Defined in +`Response.formData` -node_modules/typescript/lib/lib.dom.d.ts:4478 +*** -___ +### json() -### json +> **json**(): `Promise`\<`any`\> -▸ **json**(): `Promise`\<`any`\> +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4480 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/json) @@ -336,17 +283,15 @@ ___ #### Inherited from -Response.json - -#### Defined in +`Response.json` -node_modules/typescript/lib/lib.dom.d.ts:4480 +*** -___ +### text() -### text +> **text**(): `Promise`\<`string`\> -▸ **text**(): `Promise`\<`string`\> +Defined in: node\_modules/typescript/lib/lib.dom.d.ts:4482 [MDN Reference](https://developer.mozilla.org/docs/Web/API/Request/text) @@ -356,8 +301,4 @@ ___ #### Inherited from -Response.text - -#### Defined in - -node_modules/typescript/lib/lib.dom.d.ts:4482 \ No newline at end of file +`Response.text` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/httpvalidationerror.mdx b/weave/reference/typescript-sdk/interfaces/httpvalidationerror.mdx index fe80820264..6b250caa9c 100644 --- a/weave/reference/typescript-sdk/interfaces/httpvalidationerror.mdx +++ b/weave/reference/typescript-sdk/interfaces/httpvalidationerror.mdx @@ -5,20 +5,14 @@ description: "TypeScript SDK reference" HTTPValidationError -## Table of contents - -### Properties - -- [detail](./httpvalidationerror#detail) +Defined in: [src/generated/traceServerApi.ts:4075](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L4075) ## Properties ### detail -• `Optional` **detail**: `ValidationError`[] +> `optional` **detail**: `ValidationError`[] Detail -#### Defined in - -[src/generated/traceServerApi.ts:4077](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L4077) \ No newline at end of file +Defined in: [src/generated/traceServerApi.ts:4077](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L4077) diff --git a/weave/reference/typescript-sdk/interfaces/llm.mdx b/weave/reference/typescript-sdk/interfaces/llm.mdx new file mode 100644 index 0000000000..d40e564711 --- /dev/null +++ b/weave/reference/typescript-sdk/interfaces/llm.mdx @@ -0,0 +1,400 @@ +--- +title: "LLM" +description: "TypeScript SDK reference" +--- + +An LLM call. Emits a `chat` span with `gen_ai.*` attributes. + +Created by `weave.startLLM()` (or `turn.startLLM()`) and terminated with +`end()`. Only one LLM may be active in an async context at a time; nest +tool/subagent calls under it via `startTool` / `startSubagent`. + +Populate `inputMessages` / `outputMessages` / `usage` / `reasoning` directly, +or via the helper functions (`output`, `think`, `attachMedia`, `record`). + +All recorded data is flushed to the span at `end()`. + +Defined in: [src/genai/llm.ts:86](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L86) + +## Examples + +```ts twoslash +// @noErrors +const llm = weave.startLLM({model: 'gpt-4o-mini', providerName: 'openai'}); + +try { + llm.inputMessages = [{role: 'user', content: prompt}]; + const resp = await openai.chat.completions.create({...}); + llm.output(resp.choices[0].message.content ?? ''); + llm.record({usage: {inputTokens: resp.usage?.prompt_tokens}}); +} finally { + llm.end(); +} +``` + +```ts twoslash +// @noErrors +const llm = weave.startLLM({ + model: 'gpt-4o-mini', + providerName: 'openai', + systemInstructions: ['You are a helpful weather bot.'], + startTime: new Date('2026-05-29T10:00:00.000Z'), +}); + +try { + // ... call the LLM, populate llm.outputMessages / usage ... +} finally { + llm.end(); +} +``` + +## Extends + +- `SpanBase` + +## Properties + +### inputMessages + +> **inputMessages**: [`Message`](./message)[] = `[]` + +Input messages sent to the model. Flushed to `gen_ai.input.messages` on +`end()`. + +Defined in: [src/genai/llm.ts:93](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L93) + +*** + +### model + +> `readonly` **model**: `string` + +Defined in: [src/genai/llm.ts:117](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L117) + +*** + +### outputMessages + +> **outputMessages**: [`Message`](./message)[] = `[]` + +Assistant messages returned by the model. Flushed to +`gen_ai.output.messages` on `end()`. + +Defined in: [src/genai/llm.ts:98](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L98) + +*** + +### providerName + +> `readonly` **providerName**: `string` + +Defined in: [src/genai/llm.ts:118](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L118) + +*** + +### reasoning + +> `optional` **reasoning**: [`Reasoning`](./reasoning) + +Chain-of-thought content. Folded into the last assistant message as a +ReasoningPart at serialization time. + +Defined in: [src/genai/llm.ts:105](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L105) + +*** + +### usage + +> **usage**: [`Usage`](./usage) = `{}` + +Token counts and cache stats. Flushed to `gen_ai.usage.*` on `end()`. + +Defined in: [src/genai/llm.ts:100](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L100) + +## Methods + +### ~~addEvent()~~ + + + **Deprecated.** Record this data via [setAttributes](#setattributes) instead. +OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This +method still works and existing span-event data stays valid. +See https://opentelemetry.io/blog/2026/deprecating-span-events/ + + +> **addEvent**(`name`, `attributes?`, `startTime?`): `this` + +Add a named event to the span. Useful for marking non-span moments such as +context compaction, tool-loop detection, or guardrail trips. Warns and +no-ops after `end()`. Mirrors OTel `Span.addEvent`. + +Defined in: [src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) + +#### Parameters + +##### name + +`string` + +##### attributes? + +`Attributes` + +##### startTime? + +`TimeInput` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.addEvent('context_compacted', {removedMessages: 12}); +``` + +#### Inherited from + +`SpanBase.addEvent` + +*** + +### attachMedia() + +> **attachMedia**(`opts`): `this` + +Stage a media attachment for the LLM call. Pick exactly one of + `content` (inline base64 bytes), `uri` (URI reference), or `fileId` + (pre-uploaded file id). The attachment is glued onto the last user + message in `inputMessages` on `end()`. + +Defined in: [src/genai/llm.ts:183](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L183) + +#### Parameters + +##### opts + +`AttachMediaOpts` + +#### Returns + +`this` + +*** + +### attachMediaUrl() + +> **attachMediaUrl**(`url`, `opts`): `this` + +Convenience for `attachMedia({uri, modality})`. + +Defined in: [src/genai/llm.ts:192](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L192) + +#### Parameters + +##### url + +`string` + +##### opts + +###### modality + +[`Modality`](../type-aliases/modality) + +#### Returns + +`this` + +*** + +### end() + +> **end**(`opts?`): `void` + +Flush accumulated state and close the span. Idempotent. Pass `error` to mark failed; pass `endTime` to backdate the close. + +Defined in: [src/genai/llm.ts:274](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L274) + +#### Parameters + +##### opts? + +`SpanEndOptions` + +#### Returns + +`void` + +*** + +### output() + +> **output**(`content`): `this` + +Append an assistant message to the response. + +Defined in: [src/genai/llm.ts:155](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L155) + +#### Parameters + +##### content + +`string` + +#### Returns + +`this` + +*** + +### record() + +> **record**(`opts`): `this` + +Bulk-set any subset of the mutable fields. Replaces (does not merge). +Useful for assigning everything at once after a provider call returns. + +Defined in: [src/genai/llm.ts:203](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L203) + +#### Parameters + +##### opts + +###### finishReasons? + +`string`[] + +###### inputMessages? + +[`Message`](./message)[] + +###### mediaAttachments? + +`AttachMediaOpts`[] + +###### outputMessages? + +[`Message`](./message)[] + +###### outputType? + +`string` + +###### reasoning? + +[`Reasoning`](./reasoning) + +###### responseId? + +`string` + +###### responseModel? + +`string` + +###### usage? + +[`Usage`](./usage) + +#### Returns + +`this` + +*** + +### setAttributes() + +> **setAttributes**(`attributes`): `this` + +Set multiple attributes on the span at once. Warns and no-ops after +`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's +`set_attributes`). + +Defined in: [src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) + +#### Parameters + +##### attributes + +`Attributes` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); +``` + +#### Inherited from + +`SpanBase.setAttributes` + +*** + +### startSubagent() + +> **startSubagent**(`opts`): [`SubAgent`](./subagent) + +Start a child SubAgent span nested under this LLM. + +Defined in: [src/genai/llm.ts:261](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L261) + +#### Parameters + +##### opts + +[`SubAgentInit`](./subagentinit) + +#### Returns + +[`SubAgent`](./subagent) + +*** + +### startTool() + +> **startTool**(`opts`): [`Tool`](./tool) + +Start a child Tool span nested under this LLM. + +Defined in: [src/genai/llm.ts:252](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L252) + +#### Parameters + +##### opts + +[`ToolInit`](./toolinit) + +#### Returns + +[`Tool`](./tool) + +*** + +### think() + +> **think**(`content`): `this` + +Set or extend the model's reasoning/chain-of-thought content. Accumulates + into `this.reasoning.content`. Folded into the last assistant message as + a `ReasoningPart` at serialization time, matching the Python SDK's + on-the-wire shape. + +Defined in: [src/genai/llm.ts:167](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L167) + +#### Parameters + +##### content + +`string` + +#### Returns + +`this` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/llminit.mdx b/weave/reference/typescript-sdk/interfaces/llminit.mdx index 892b97c754..80010cb37e 100644 --- a/weave/reference/typescript-sdk/interfaces/llminit.mdx +++ b/weave/reference/typescript-sdk/interfaces/llminit.mdx @@ -3,61 +3,44 @@ title: "LLMInit" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/genai/llm.ts:36](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L36) -- `SpanInitBase` - - ↳ `LLMInit` - -## Table of contents +## Extends -### Properties - -- [model](./llminit#model) -- [providerName](./llminit#providername) -- [startTime](./llminit#starttime) -- [systemInstructions](./llminit#systeminstructions) +- `SpanInitBase` ## Properties ### model -• **model**: `string` - -#### Defined in +> **model**: `string` -[src/genai/llm.ts:37](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L37) +Defined in: [src/genai/llm.ts:37](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L37) -___ +*** ### providerName -• `Optional` **providerName**: `string` +> `optional` **providerName**: `string` -#### Defined in +Defined in: [src/genai/llm.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L38) -[src/genai/llm.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L38) - -___ +*** ### startTime -• `Optional` **startTime**: `TimeInput` - -#### Inherited from +> `optional` **startTime**: `TimeInput` -SpanInitBase.startTime +Defined in: [src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) -#### Defined in +#### Inherited from -[src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) +`SpanInitBase.startTime` -___ +*** ### systemInstructions -• `Optional` **systemInstructions**: `string`[] - -#### Defined in +> `optional` **systemInstructions**: `string`[] -[src/genai/llm.ts:39](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L39) \ No newline at end of file +Defined in: [src/genai/llm.ts:39](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/llm.ts#L39) diff --git a/weave/reference/typescript-sdk/interfaces/message.mdx b/weave/reference/typescript-sdk/interfaces/message.mdx index 73528ba627..a956998876 100644 --- a/weave/reference/typescript-sdk/interfaces/message.mdx +++ b/weave/reference/typescript-sdk/interfaces/message.mdx @@ -3,62 +3,44 @@ title: "Message" description: "TypeScript SDK reference" --- -## Table of contents - -### Properties - -- [content](./message#content) -- [parts](./message#parts) -- [role](./message#role) -- [toolCallId](./message#toolcallid) -- [toolName](./message#toolname) +Defined in: [src/genai/types.ts:15](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L15) ## Properties ### content -• `Optional` **content**: `string` +> `optional` **content**: `string` -#### Defined in +Defined in: [src/genai/types.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L17) -[src/genai/types.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L17) - -___ +*** ### parts -• `Optional` **parts**: [`MessagePart`](../#messagepart)[] - -#### Defined in +> `optional` **parts**: [`MessagePart`](../type-aliases/messagepart)[] -[src/genai/types.ts:20](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L20) +Defined in: [src/genai/types.ts:20](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L20) -___ +*** ### role -• **role**: [`Role`](../#role) +> **role**: [`Role`](../type-aliases/role) -#### Defined in +Defined in: [src/genai/types.ts:16](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L16) -[src/genai/types.ts:16](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L16) - -___ +*** ### toolCallId -• `Optional` **toolCallId**: `string` - -#### Defined in +> `optional` **toolCallId**: `string` -[src/genai/types.ts:18](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L18) +Defined in: [src/genai/types.ts:18](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L18) -___ +*** ### toolName -• `Optional` **toolName**: `string` - -#### Defined in +> `optional` **toolName**: `string` -[src/genai/types.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L19) \ No newline at end of file +Defined in: [src/genai/types.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L19) diff --git a/weave/reference/typescript-sdk/interfaces/query.mdx b/weave/reference/typescript-sdk/interfaces/query.mdx index 9ece97ec7b..36731a7630 100644 --- a/weave/reference/typescript-sdk/interfaces/query.mdx +++ b/weave/reference/typescript-sdk/interfaces/query.mdx @@ -5,20 +5,14 @@ description: "TypeScript SDK reference" Query -## Table of contents - -### Properties - -- [$expr](./query#$expr) +Defined in: [src/generated/traceServerApi.ts:5222](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5222) ## Properties ### $expr -• **$expr**: `AndOperation` \| `OrOperation` \| `NotOperation` \| `EqOperation` \| `GtOperation` \| `LtOperation` \| `GteOperation` \| `LteOperation` \| `InOperation` \| `ContainsOperation` +> **$expr**: `AndOperation` \| `OrOperation` \| `NotOperation` \| `EqOperation` \| `GtOperation` \| `LtOperation` \| `GteOperation` \| `LteOperation` \| `InOperation` \| `ContainsOperation` $Expr -#### Defined in - -[src/generated/traceServerApi.ts:5224](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5224) \ No newline at end of file +Defined in: [src/generated/traceServerApi.ts:5224](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5224) diff --git a/weave/reference/typescript-sdk/interfaces/reasoning.mdx b/weave/reference/typescript-sdk/interfaces/reasoning.mdx index 333458c587..5a6929669b 100644 --- a/weave/reference/typescript-sdk/interfaces/reasoning.mdx +++ b/weave/reference/typescript-sdk/interfaces/reasoning.mdx @@ -3,18 +3,12 @@ title: "Reasoning" description: "TypeScript SDK reference" --- -## Table of contents - -### Properties - -- [content](./reasoning#content) +Defined in: [src/genai/types.ts:45](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L45) ## Properties ### content -• **content**: `string` - -#### Defined in +> **content**: `string` -[src/genai/types.ts:46](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L46) \ No newline at end of file +Defined in: [src/genai/types.ts:46](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L46) diff --git a/weave/reference/typescript-sdk/interfaces/sortby.mdx b/weave/reference/typescript-sdk/interfaces/sortby.mdx index 05e50a20ec..5bd97bc6d7 100644 --- a/weave/reference/typescript-sdk/interfaces/sortby.mdx +++ b/weave/reference/typescript-sdk/interfaces/sortby.mdx @@ -5,33 +5,24 @@ description: "TypeScript SDK reference" SortBy -## Table of contents - -### Properties - -- [direction](./sortby#direction) -- [field](./sortby#field) +Defined in: [src/generated/traceServerApi.ts:5536](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5536) ## Properties ### direction -• **direction**: ``"asc"`` \| ``"desc"`` +> **direction**: `"asc"` \| `"desc"` Direction -#### Defined in +Defined in: [src/generated/traceServerApi.ts:5540](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5540) -[src/generated/traceServerApi.ts:5540](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5540) - -___ +*** ### field -• **field**: `string` +> **field**: `string` Field -#### Defined in - -[src/generated/traceServerApi.ts:5538](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5538) \ No newline at end of file +Defined in: [src/generated/traceServerApi.ts:5538](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/generated/traceServerApi.ts#L5538) diff --git a/weave/reference/typescript-sdk/interfaces/subagent.mdx b/weave/reference/typescript-sdk/interfaces/subagent.mdx new file mode 100644 index 0000000000..3e17dbf0d3 --- /dev/null +++ b/weave/reference/typescript-sdk/interfaces/subagent.mdx @@ -0,0 +1,183 @@ +--- +title: "SubAgent" +description: "TypeScript SDK reference" +--- + +Defined in: [src/genai/subagent.ts:65](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L65) + +## Extends + +- `SpanBase` + +## Accessors + +### model + +#### Get Signature + +> **get** **model**(): `string` + +Defined in: [src/genai/subagent.ts:78](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L78) + +##### Returns + +`string` + +*** + +### name + +#### Get Signature + +> **get** **name**(): `string` + +Defined in: [src/genai/subagent.ts:74](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L74) + +##### Returns + +`string` + +## Methods + +### ~~addEvent()~~ + + + **Deprecated.** Record this data via [setAttributes](#setattributes) instead. +OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This +method still works and existing span-event data stays valid. +See https://opentelemetry.io/blog/2026/deprecating-span-events/ + + +> **addEvent**(`name`, `attributes?`, `startTime?`): `this` + +Add a named event to the span. Useful for marking non-span moments such as +context compaction, tool-loop detection, or guardrail trips. Warns and +no-ops after `end()`. Mirrors OTel `Span.addEvent`. + +Defined in: [src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) + +#### Parameters + +##### name + +`string` + +##### attributes? + +`Attributes` + +##### startTime? + +`TimeInput` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.addEvent('context_compacted', {removedMessages: 12}); +``` + +#### Inherited from + +`SpanBase.addEvent` + +*** + +### end() + +> **end**(`opts?`): `void` + +Read current field values (to reflect mutations made via `record()` +since `start`) and close the span. Idempotent. Pass `error` to mark +it as failed; pass `endTime` to backdate the close. + +Defined in: [src/genai/subagent.ts:153](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L153) + +#### Parameters + +##### opts? + +`SpanEndOptions` + +#### Returns + +`void` + +*** + +### record() + +> **record**(`opts`): `this` + +Bulk-set any fields. Replaces (does not merge). + +Defined in: [src/genai/subagent.ts:117](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L117) + +#### Parameters + +##### opts + +###### agentDescription? + +`string` + +###### agentId? + +`string` + +###### agentVersion? + +`string` + +###### model? + +`string` + +###### name? + +`string` + +###### systemInstructions? + +`string`[] + +#### Returns + +`this` + +*** + +### setAttributes() + +> **setAttributes**(`attributes`): `this` + +Set multiple attributes on the span at once. Warns and no-ops after +`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's +`set_attributes`). + +Defined in: [src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) + +#### Parameters + +##### attributes + +`Attributes` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); +``` + +#### Inherited from + +`SpanBase.setAttributes` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/subagentinit.mdx b/weave/reference/typescript-sdk/interfaces/subagentinit.mdx index 27bdd20472..2e5bebf1ea 100644 --- a/weave/reference/typescript-sdk/interfaces/subagentinit.mdx +++ b/weave/reference/typescript-sdk/interfaces/subagentinit.mdx @@ -3,94 +3,68 @@ title: "SubAgentInit" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/genai/subagent.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L19) -- `SpanInitBase` - - ↳ `SubAgentInit` - -## Table of contents - -### Properties +## Extends -- [agentDescription](./subagentinit#agentdescription) -- [agentId](./subagentinit#agentid) -- [agentVersion](./subagentinit#agentversion) -- [model](./subagentinit#model) -- [name](./subagentinit#name) -- [startTime](./subagentinit#starttime) -- [systemInstructions](./subagentinit#systeminstructions) +- `SpanInitBase` ## Properties ### agentDescription -• `Optional` **agentDescription**: `string` - -#### Defined in +> `optional` **agentDescription**: `string` -[src/genai/subagent.ts:24](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L24) +Defined in: [src/genai/subagent.ts:24](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L24) -___ +*** ### agentId -• `Optional` **agentId**: `string` - -#### Defined in +> `optional` **agentId**: `string` -[src/genai/subagent.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L23) +Defined in: [src/genai/subagent.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L23) -___ +*** ### agentVersion -• `Optional` **agentVersion**: `string` +> `optional` **agentVersion**: `string` -#### Defined in +Defined in: [src/genai/subagent.ts:25](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L25) -[src/genai/subagent.ts:25](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L25) - -___ +*** ### model -• `Optional` **model**: `string` - -#### Defined in +> `optional` **model**: `string` -[src/genai/subagent.ts:21](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L21) +Defined in: [src/genai/subagent.ts:21](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L21) -___ +*** ### name -• **name**: `string` +> **name**: `string` -#### Defined in +Defined in: [src/genai/subagent.ts:20](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L20) -[src/genai/subagent.ts:20](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L20) - -___ +*** ### startTime -• `Optional` **startTime**: `TimeInput` +> `optional` **startTime**: `TimeInput` -#### Inherited from +Defined in: [src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) -SpanInitBase.startTime - -#### Defined in +#### Inherited from -[src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) +`SpanInitBase.startTime` -___ +*** ### systemInstructions -• `Optional` **systemInstructions**: `string`[] - -#### Defined in +> `optional` **systemInstructions**: `string`[] -[src/genai/subagent.ts:22](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L22) \ No newline at end of file +Defined in: [src/genai/subagent.ts:22](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/subagent.ts#L22) diff --git a/weave/reference/typescript-sdk/interfaces/tool.mdx b/weave/reference/typescript-sdk/interfaces/tool.mdx new file mode 100644 index 0000000000..0426626dd0 --- /dev/null +++ b/weave/reference/typescript-sdk/interfaces/tool.mdx @@ -0,0 +1,169 @@ +--- +title: "Tool" +description: "TypeScript SDK reference" +--- + +A tool invocation. Emits an `execute_tool` span carrying the tool name, +the JSON-encoded arguments, the tool-call id, and the result. + +Created by `weave.startTool()` (or `turn.startTool()`, or +`llm.startTool()`) and terminated with `end()`. Assign `result` before +calling `end()` to record the tool's output on the span. + +Defined in: [src/genai/tool.ts:43](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L43) + +## Example + +```ts twoslash +// @noErrors +const tool = weave.startTool({ + name: tc.function.name, + args: tc.function.arguments, + toolCallId: tc.id, +}); +try { + tool.result = await wikipediaSearch(JSON.parse(tc.function.arguments)); +} finally { + tool.end(); +} +``` + +## Extends + +- `SpanBase` + +## Properties + +### args + +> `readonly` **args**: `string` + +Defined in: [src/genai/tool.ts:52](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L52) + +*** + +### name + +> `readonly` **name**: `string` + +Defined in: [src/genai/tool.ts:51](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L51) + +*** + +### result + +> `optional` **result**: `string` + +Tool output as a string. Recorded on `gen_ai.tool.call.result` at `end()`. + +Defined in: [src/genai/tool.ts:47](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L47) + +*** + +### toolCallId + +> `readonly` **toolCallId**: `string` + +Defined in: [src/genai/tool.ts:53](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L53) + +## Methods + +### ~~addEvent()~~ + + + **Deprecated.** Record this data via [setAttributes](#setattributes) instead. +OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This +method still works and existing span-event data stays valid. +See https://opentelemetry.io/blog/2026/deprecating-span-events/ + + +> **addEvent**(`name`, `attributes?`, `startTime?`): `this` + +Add a named event to the span. Useful for marking non-span moments such as +context compaction, tool-loop detection, or guardrail trips. Warns and +no-ops after `end()`. Mirrors OTel `Span.addEvent`. + +Defined in: [src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) + +#### Parameters + +##### name + +`string` + +##### attributes? + +`Attributes` + +##### startTime? + +`TimeInput` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.addEvent('context_compacted', {removedMessages: 12}); +``` + +#### Inherited from + +`SpanBase.addEvent` + +*** + +### end() + +> **end**(`opts?`): `void` + +Flush `result` to the span and close it. Idempotent. Pass `error` to mark +the span as failed; pass `endTime` to backdate the close. + +Defined in: [src/genai/tool.ts:87](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L87) + +#### Parameters + +##### opts? + +`SpanEndOptions` + +#### Returns + +`void` + +*** + +### setAttributes() + +> **setAttributes**(`attributes`): `this` + +Set multiple attributes on the span at once. Warns and no-ops after +`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's +`set_attributes`). + +Defined in: [src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) + +#### Parameters + +##### attributes + +`Attributes` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); +``` + +#### Inherited from + +`SpanBase.setAttributes` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/toolinit.mdx b/weave/reference/typescript-sdk/interfaces/toolinit.mdx index fa20989d46..aebab5114b 100644 --- a/weave/reference/typescript-sdk/interfaces/toolinit.mdx +++ b/weave/reference/typescript-sdk/interfaces/toolinit.mdx @@ -3,61 +3,44 @@ title: "ToolInit" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/genai/tool.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L17) -- `SpanInitBase` - - ↳ `ToolInit` - -## Table of contents +## Extends -### Properties - -- [args](./toolinit#args) -- [name](./toolinit#name) -- [startTime](./toolinit#starttime) -- [toolCallId](./toolinit#toolcallid) +- `SpanInitBase` ## Properties ### args -• `Optional` **args**: `string` - -#### Defined in +> `optional` **args**: `string` -[src/genai/tool.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L19) +Defined in: [src/genai/tool.ts:19](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L19) -___ +*** ### name -• **name**: `string` +> **name**: `string` -#### Defined in +Defined in: [src/genai/tool.ts:18](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L18) -[src/genai/tool.ts:18](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L18) - -___ +*** ### startTime -• `Optional` **startTime**: `TimeInput` - -#### Inherited from +> `optional` **startTime**: `TimeInput` -SpanInitBase.startTime +Defined in: [src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) -#### Defined in +#### Inherited from -[src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) +`SpanInitBase.startTime` -___ +*** ### toolCallId -• `Optional` **toolCallId**: `string` - -#### Defined in +> `optional` **toolCallId**: `string` -[src/genai/tool.ts:20](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L20) \ No newline at end of file +Defined in: [src/genai/tool.ts:20](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/tool.ts#L20) diff --git a/weave/reference/typescript-sdk/interfaces/turn.mdx b/weave/reference/typescript-sdk/interfaces/turn.mdx new file mode 100644 index 0000000000..1508390624 --- /dev/null +++ b/weave/reference/typescript-sdk/interfaces/turn.mdx @@ -0,0 +1,277 @@ +--- +title: "Turn" +description: "TypeScript SDK reference" +--- + +Defined in: [src/genai/turn.ts:92](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L92) + +## Extends + +- `SpanBase` + +## Accessors + +### agentName + +#### Get Signature + +> **get** **agentName**(): `string` + +Defined in: [src/genai/turn.ts:103](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L103) + +##### Returns + +`string` + +*** + +### model + +#### Get Signature + +> **get** **model**(): `string` + +Defined in: [src/genai/turn.ts:107](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L107) + +##### Returns + +`string` + +## Methods + +### ~~addEvent()~~ + + + **Deprecated.** Record this data via [setAttributes](#setattributes) instead. +OpenTelemetry is phasing out the Span Event API (`Span.addEvent`). This +method still works and existing span-event data stays valid. +See https://opentelemetry.io/blog/2026/deprecating-span-events/ + + +> **addEvent**(`name`, `attributes?`, `startTime?`): `this` + +Add a named event to the span. Useful for marking non-span moments such as +context compaction, tool-loop detection, or guardrail trips. Warns and +no-ops after `end()`. Mirrors OTel `Span.addEvent`. + +Defined in: [src/genai/spanBase.ts:82](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L82) + +#### Parameters + +##### name + +`string` + +##### attributes? + +`Attributes` + +##### startTime? + +`TimeInput` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.addEvent('context_compacted', {removedMessages: 12}); +``` + +#### Inherited from + +`SpanBase.addEvent` + +*** + +### end() + +> **end**(`opts?`): `void` + +Read current field values (to reflect mutations made via `record()` +since `start`) and close the span. Idempotent. Pass `error` to mark +it as failed; pass `endTime` to backdate the close. + +Defined in: [src/genai/turn.ts:241](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L241) + +#### Parameters + +##### opts? + +`SpanEndOptions` + +#### Returns + +`void` + +*** + +### record() + +> **record**(`opts`): `this` + +Bulk-set any subset of the mutable fields. Replaces (does not merge). +Useful for assigning everything at once after a provider call returns. + +Defined in: [src/genai/turn.ts:201](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L201) + +#### Parameters + +##### opts + +###### agentDescription? + +`string` + +###### agentId? + +`string` + +###### agentName? + +`string` + +###### agentVersion? + +`string` + +###### messages? + +[`Message`](./message)[] + +###### model? + +`string` + +###### systemInstructions? + +`string`[] + +#### Returns + +`this` + +*** + +### ~~setAttribute()~~ + + + **Deprecated.** Use [setAttributes](#setattributes) instead, which mirrors the Python +SDK's `set_attributes` and OTel's `Span.setAttributes`. Retained as a thin +alias so existing single-attribute callers keep working. Only `Turn` +carries this — the other emitters never shipped a singular form. + + +> **setAttribute**(`key`, `value`): `this` + +Defined in: [src/genai/turn.ts:193](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L193) + +#### Parameters + +##### key + +`string` + +##### value + +`AttributeValue` + +#### Returns + +`this` + +*** + +### setAttributes() + +> **setAttributes**(`attributes`): `this` + +Set multiple attributes on the span at once. Warns and no-ops after +`end()`. Mirrors OTel `Span.setAttributes` (and the Python SDK's +`set_attributes`). + +Defined in: [src/genai/spanBase.ts:63](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L63) + +#### Parameters + +##### attributes + +`Attributes` + +#### Returns + +`this` + +#### Example + +```ts twoslash +// @noErrors +span.setAttributes({'weave.tag': 'prod', 'gen_ai.response.id': id}); +``` + +#### Inherited from + +`SpanBase.setAttributes` + +*** + +### startLLM() + +> **startLLM**(`opts`): [`LLM`](./llm) + +Start a child LLM span under this Turn. + +Defined in: [src/genai/turn.ts:161](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L161) + +#### Parameters + +##### opts + +[`LLMInit`](./llminit) + +#### Returns + +[`LLM`](./llm) + +*** + +### startSubagent() + +> **startSubagent**(`opts`): [`SubAgent`](./subagent) + +Start a child SubAgent span under this Turn. + +Defined in: [src/genai/turn.ts:179](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L179) + +#### Parameters + +##### opts + +[`SubAgentInit`](./subagentinit) + +#### Returns + +[`SubAgent`](./subagent) + +*** + +### startTool() + +> **startTool**(`opts`): [`Tool`](./tool) + +Start a child Tool span under this Turn. + +Defined in: [src/genai/turn.ts:170](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L170) + +#### Parameters + +##### opts + +[`ToolInit`](./toolinit) + +#### Returns + +[`Tool`](./tool) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/turninit.mdx b/weave/reference/typescript-sdk/interfaces/turninit.mdx index b2e1bceab2..43c86fdaa1 100644 --- a/weave/reference/typescript-sdk/interfaces/turninit.mdx +++ b/weave/reference/typescript-sdk/interfaces/turninit.mdx @@ -3,105 +3,76 @@ title: "TurnInit" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/genai/turn.ts:31](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L31) -- `SpanInitBase` - - ↳ `TurnInit` - -## Table of contents - -### Properties +## Extends -- [agentDescription](./turninit#agentdescription) -- [agentId](./turninit#agentid) -- [agentName](./turninit#agentname) -- [agentVersion](./turninit#agentversion) -- [model](./turninit#model) -- [startTime](./turninit#starttime) -- [systemInstructions](./turninit#systeminstructions) -- [userMessage](./turninit#usermessage) +- `SpanInitBase` ## Properties ### agentDescription -• `Optional` **agentDescription**: `string` - -#### Defined in +> `optional` **agentDescription**: `string` -[src/genai/turn.ts:37](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L37) +Defined in: [src/genai/turn.ts:37](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L37) -___ +*** ### agentId -• `Optional` **agentId**: `string` +> `optional` **agentId**: `string` -#### Defined in +Defined in: [src/genai/turn.ts:35](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L35) -[src/genai/turn.ts:35](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L35) - -___ +*** ### agentName -• `Optional` **agentName**: `string` - -#### Defined in +> `optional` **agentName**: `string` -[src/genai/turn.ts:36](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L36) +Defined in: [src/genai/turn.ts:36](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L36) -___ +*** ### agentVersion -• `Optional` **agentVersion**: `string` +> `optional` **agentVersion**: `string` -#### Defined in +Defined in: [src/genai/turn.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L38) -[src/genai/turn.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L38) - -___ +*** ### model -• `Optional` **model**: `string` - -#### Defined in +> `optional` **model**: `string` -[src/genai/turn.ts:32](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L32) +Defined in: [src/genai/turn.ts:32](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L32) -___ +*** ### startTime -• `Optional` **startTime**: `TimeInput` - -#### Inherited from +> `optional` **startTime**: `TimeInput` -SpanInitBase.startTime +Defined in: [src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) -#### Defined in +#### Inherited from -[src/genai/spanBase.ts:17](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/spanBase.ts#L17) +`SpanInitBase.startTime` -___ +*** ### systemInstructions -• `Optional` **systemInstructions**: `string`[] - -#### Defined in +> `optional` **systemInstructions**: `string`[] -[src/genai/turn.ts:33](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L33) +Defined in: [src/genai/turn.ts:33](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L33) -___ +*** ### userMessage -• `Optional` **userMessage**: `string` - -#### Defined in +> `optional` **userMessage**: `string` -[src/genai/turn.ts:34](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L34) \ No newline at end of file +Defined in: [src/genai/turn.ts:34](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/turn.ts#L34) diff --git a/weave/reference/typescript-sdk/interfaces/usage.mdx b/weave/reference/typescript-sdk/interfaces/usage.mdx index ef3682bbad..baba93aea1 100644 --- a/weave/reference/typescript-sdk/interfaces/usage.mdx +++ b/weave/reference/typescript-sdk/interfaces/usage.mdx @@ -3,62 +3,44 @@ title: "Usage" description: "TypeScript SDK reference" --- -## Table of contents - -### Properties - -- [cacheCreationInputTokens](./usage#cachecreationinputtokens) -- [cacheReadInputTokens](./usage#cachereadinputtokens) -- [inputTokens](./usage#inputtokens) -- [outputTokens](./usage#outputtokens) -- [reasoningTokens](./usage#reasoningtokens) +Defined in: [src/genai/types.ts:37](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L37) ## Properties ### cacheCreationInputTokens -• `Optional` **cacheCreationInputTokens**: `number` +> `optional` **cacheCreationInputTokens**: `number` -#### Defined in +Defined in: [src/genai/types.ts:41](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L41) -[src/genai/types.ts:41](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L41) - -___ +*** ### cacheReadInputTokens -• `Optional` **cacheReadInputTokens**: `number` - -#### Defined in +> `optional` **cacheReadInputTokens**: `number` -[src/genai/types.ts:42](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L42) +Defined in: [src/genai/types.ts:42](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L42) -___ +*** ### inputTokens -• `Optional` **inputTokens**: `number` +> `optional` **inputTokens**: `number` -#### Defined in +Defined in: [src/genai/types.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L38) -[src/genai/types.ts:38](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L38) - -___ +*** ### outputTokens -• `Optional` **outputTokens**: `number` - -#### Defined in +> `optional` **outputTokens**: `number` -[src/genai/types.ts:39](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L39) +Defined in: [src/genai/types.ts:39](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L39) -___ +*** ### reasoningTokens -• `Optional` **reasoningTokens**: `number` - -#### Defined in +> `optional` **reasoningTokens**: `number` -[src/genai/types.ts:40](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L40) \ No newline at end of file +Defined in: [src/genai/types.ts:40](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L40) diff --git a/weave/reference/typescript-sdk/interfaces/weaveaudio.mdx b/weave/reference/typescript-sdk/interfaces/weaveaudio.mdx index 55be1659a7..95d1a32c95 100644 --- a/weave/reference/typescript-sdk/interfaces/weaveaudio.mdx +++ b/weave/reference/typescript-sdk/interfaces/weaveaudio.mdx @@ -3,54 +3,40 @@ title: "WeaveAudio" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/media.ts:47](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L47) -- `WeaveAudioInput` - - ↳ `WeaveAudio` - -## Table of contents +## Extends -### Properties - -- [\_weaveType](./weaveaudio#_weavetype) -- [audioType](./weaveaudio#audiotype) -- [data](./weaveaudio#data) +- `WeaveAudioInput` ## Properties ### \_weaveType -• **\_weaveType**: ``"Audio"`` - -#### Defined in +> **\_weaveType**: `"Audio"` -[src/media.ts:48](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L48) +Defined in: [src/media.ts:48](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L48) -___ +*** ### audioType -• `Optional` **audioType**: ``"wav"`` +> `optional` **audioType**: `"wav"` -#### Inherited from - -WeaveAudioInput.audioType +Defined in: [src/media.ts:44](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L44) -#### Defined in +#### Inherited from -[src/media.ts:44](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L44) +`WeaveAudioInput.audioType` -___ +*** ### data -• **data**: `Buffer`\<`ArrayBufferLike`\> +> **data**: `Buffer` -#### Inherited from - -WeaveAudioInput.data +Defined in: [src/media.ts:43](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L43) -#### Defined in +#### Inherited from -[src/media.ts:43](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L43) \ No newline at end of file +`WeaveAudioInput.data` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/weaveclient.mdx b/weave/reference/typescript-sdk/interfaces/weaveclient.mdx new file mode 100644 index 0000000000..2ec8369dc4 --- /dev/null +++ b/weave/reference/typescript-sdk/interfaces/weaveclient.mdx @@ -0,0 +1,951 @@ +--- +title: "WeaveClient" +description: "TypeScript SDK reference" +--- + +Defined in: [src/weaveClient.ts:445](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L445) + +## Properties + +### projectId + +> **projectId**: `string` + +Defined in: [src/weaveClient.ts:456](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L456) + +*** + +### settings + +> **settings**: [`Settings`](../type-aliases/settings) + +Defined in: [src/weaveClient.ts:457](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L457) + +*** + +### traceServerApi + +> **traceServerApi**: `Api`\<`any`\> + +Defined in: [src/weaveClient.ts:455](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L455) + +## Methods + +### addScore() + +> **addScore**(`predictCallId`, `scorerCallId`, `runnableRefUri`, `scorerOutput`): `Promise`\<`string`\> + +Add a scorer result (e.g., scorer output) to a call. +Used in imperative evaluation to attach scorer results to predict calls. + +Defined in: [src/weaveClient.ts:1727](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1727) + +#### Parameters + +##### predictCallId + +`string` + +ID of the predict call to attach feedback to + +##### scorerCallId + +`string` + +ID of the scorer call that generated the feedback + +##### runnableRefUri + +`string` + +URI of the scorer (Op or Object ref) + +##### scorerOutput + +`any` + +Output of the scorer + +#### Returns + +`Promise`\<`string`\> + +*** + +### createCall() + +> **createCall**(`internalCall`, `opRef`, `params`, `parameterNames`, `thisArg`, `currentCall`, `parentCall`, `startTime`, `displayName?`, `attributes?`): `Promise`\<`void`\> + +Defined in: [src/weaveClient.ts:1570](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1570) + +#### Parameters + +##### internalCall + +`InternalCall` + +##### opRef + +`any` + +##### params + +`any`[] + +##### parameterNames + +`ParameterNamesOption` + +##### thisArg + +`any` + +##### currentCall + +`CallStackEntry` + +##### parentCall + +`CallStackEntry` \| `undefined` + +##### startTime + +`Date` + +##### displayName? + +`string` + +##### attributes? + +`Record`\<`string`, `any`\> + +#### Returns + +`Promise`\<`void`\> + +*** + +### finishCall() + +> **finishCall**(`call`, `result`, `currentCall`, `parentCall`, `summarize`, `endTime`, `startCallPromise`): `Promise`\<`void`\> + +Defined in: [src/weaveClient.ts:1630](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1630) + +#### Parameters + +##### call + +`InternalCall` + +##### result + +`any` + +##### currentCall + +`CallStackEntry` + +##### parentCall + +`CallStackEntry` \| `undefined` + +##### summarize + +((`result`) => `Record`\<`string`, `any`\>) \| `undefined` + +##### endTime + +`Date` + +##### startCallPromise + +`Promise`\<`void`\> + +#### Returns + +`Promise`\<`void`\> + +*** + +### finishCallWithException() + +> **finishCallWithException**(`call`, `error`, `currentCall`, `parentCall`, `endTime`, `startCallPromise`): `Promise`\<`void`\> + +Defined in: [src/weaveClient.ts:1672](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1672) + +#### Parameters + +##### call + +`InternalCall` + +##### error + +`any` + +##### currentCall + +`CallStackEntry` + +##### parentCall + +`CallStackEntry` \| `undefined` + +##### endTime + +`Date` + +##### startCallPromise + +`Promise`\<`void`\> + +#### Returns + +`Promise`\<`void`\> + +*** + +### get() + +> **get**(`ref`): `Promise`\<`any`\> + +Defined in: [src/weaveClient.ts:1025](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1025) + +#### Parameters + +##### ref + +[`ObjectRef`](../classes/objectref) + +#### Returns + +`Promise`\<`any`\> + +*** + +### getAgentCustomAttributes() + +> **getAgentCustomAttributes**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<`GetAgentCustomAttributesResult`\>\> + +Discover typed custom-attribute keys observed on agent spans in the +project. Each result row is one `(source, key, value_type)` triple plus +a count of how many spans carry it, which is what the spans +query/group/stats APIs use to reference custom attrs. + +Filter the spans considered by passing `query` (a structured span +filter), `startedAfter` / `startedBefore` (ISO-8601), or both. Use +`limit` / `offset` to page through the discovered keys. + +Defined in: [src/weaveClient.ts:772](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L772) + +#### Parameters + +##### options + +`GetAgentCustomAttributesOptions` + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<`GetAgentCustomAttributesResult`\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgentCustomAttributes({ + query: { + $expr: { + $eq: [{$getField: 'agent_name'}, {$literal: 'my-agent'}], + }, + }, + startedAfter: '2026-06-15T00:00:00Z', + limit: 200, +}); + +for (const attr of resp.data.attributes ?? []) { + console.log(`${attr.source}.${attr.key} (${attr.value_type}): ${attr.span_count}`); +} +``` + +*** + +### getAgents() + +> **getAgents**(`options?`): `Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentsResult`](../type-aliases/getagentsresult)\>\> + +List agents with aggregated stats. + +Defined in: [src/weaveClient.ts:488](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L488) + +#### Parameters + +##### options? + +[`GetAgentsOptions`](./getagentsoptions) = `{}` + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentsResult`](../type-aliases/getagentsresult)\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgents({limit: 20}); + +for (const agent of resp.data.agents) { + console.log(agent.agent_name, agent.total_input_tokens); +} + +console.log(`total count: ${resp.data.total_count}`) +``` + +*** + +### getAgentSpans() + +> **getAgentSpans**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentSpansResult`](../type-aliases/getagentspansresult)\>\> + +Query agent spans, optionally filtered by agent name and/or a mongo-style +query expression. + +Defined in: [src/weaveClient.ts:566](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L566) + +#### Parameters + +##### options + +[`GetAgentSpansOptions`](./getagentspansoptions) + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentSpansResult`](../type-aliases/getagentspansresult)\>\> + +#### Examples + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgentSpans({agentName: 'my-agent', limit: 20}); + +for (const span of resp.data.spans) { + console.log(span.span_id, span.span_name, span.input_tokens); +} +``` + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); + +const resp = await client.getAgentSpans({ + agentName: 'my-agent', + query: { + $expr: {$gt: [{$getField: 'input_tokens'}, {$literal: 1000}]}, + }, +}); + +for (const span of resp.data.spans) { + console.log(span.span_id, span.span_name, span.input_tokens); +} +``` + +*** + +### getAgentSpanStats() + +> **getAgentSpanStats**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<`GetAgentSpanStatsResult`\>\> + +Agregations over agent spans in the project, returned as rows + column +metadata suitable for time-series / bucketed visualizations. + +`start` (required) and `end` define the time window. Each entry in +`metrics` declares a field to extract and how to aggregate it (`sum`, +`avg`, `count`, percentiles, etc.). Pass `granularity` (seconds) to +bucket rows by time, or `groupBy` to break results out per agent / +provider / model / etc. `query` filters the underlying spans before +aggregation. + +Defined in: [src/weaveClient.ts:621](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L621) + +#### Parameters + +##### options + +`GetAgentSpanStatsOptions` + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<`GetAgentSpanStatsResult`\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgentSpanStats({ + start: '2026-06-10T00:00:00Z', + end: '2026-06-23T00:00:00Z', + granularity: 86400, // one row per day + metrics: [ + { + alias: 'total_input_tokens', + value_type: 'number', + aggregations: ['sum'], + value: {source: 'field', key: 'input_tokens'}, + }, + ], + groupBy: [{key: 'agent_name'}], +}); + +for (const row of resp.data.rows ?? []) { + console.log(row.started_at_bucket, row.agent_name, row.total_input_tokens); +} +``` + +*** + +### getAgentTurn() + +> **getAgentTurn**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<`AgentTraceChatRes`\>\> + +Get data (including messages) for a single turn (by traceId). + +Defined in: [src/weaveClient.ts:655](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L655) + +#### Parameters + +##### options + +[`GetAgentTurnOptions`](./getagentturnoptions) + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<`AgentTraceChatRes`\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgentTurn({ + traceId: '01997b8a-2c89-7c4d-9d0e-2f7e5b9a1b2c', + includeFeedback: true, +}); + +console.log(resp.data.root_span_name, resp.data.total_duration_ms); + +for (const message of resp.data.messages ?? []) { + if (message.user_message) console.log('user:', message.user_message); + if (message.assistant_message) console.log('assistant:', message.assistant_message); +} +``` + +*** + +### getAgentTurns() + +> **getAgentTurns**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentTurnsResult`](../type-aliases/getagentturnsresult)\>\> + +Get data (including messages) for many turns (by conversationId). + +Defined in: [src/weaveClient.ts:688](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L688) + +#### Parameters + +##### options + +[`GetAgentTurnsOptions`](./getagentturnsoptions) + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentTurnsResult`](../type-aliases/getagentturnsresult)\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgentTurns({ + conversationId: 'trace_c50312356de3487fa90e381c9399b5b4', + limit: 20, + includeFeedback: true, +}); + +for (const turn of resp.data.turns ?? []) { + console.log(turn.trace_id, turn.root_span_name); + for (const message of turn.messages ?? []) { + if (message.user_message) console.log('user:', message.user_message); + if (message.assistant_message) console.log('assistant:', message.assistant_message); + } +} + +console.log(`total turns: ${resp.data.total_turns}, has more: ${resp.data.has_more}`); +``` + +*** + +### getAgentVersions() + +> **getAgentVersions**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentVersionsResult`](../type-aliases/getagentversionsresult)\>\> + +List versions for a given agent. + +Defined in: [src/weaveClient.ts:522](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L522) + +#### Parameters + +##### options + +[`GetAgentVersionsOptions`](./getagentversionsoptions) + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<[`GetAgentVersionsResult`](../type-aliases/getagentversionsresult)\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.getAgentVersions({agentName: 'my-agent', limit: 20}); + +for (const version of resp.data.versions) { + console.log(version.agent_version, version.total_input_tokens); +} + +console.log(`total count: ${resp.data.total_count}`) +``` + +*** + +### getCall() + +> **getCall**(`callId`, `includeCosts?`): `Promise`\<`Call`\> + +Defined in: [src/weaveClient.ts:902](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L902) + +#### Parameters + +##### callId + +`string` + +##### includeCosts? + +`boolean` = `false` + +#### Returns + +`Promise`\<`Call`\> + +*** + +### getCalls() + +#### Call Signature + +> **getCalls**(`options?`): `Promise`\<`Call`[]\> + +Defined in: [src/weaveClient.ts:935](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L935) + +##### Parameters + +###### options? + +[`GetCallsOptions`](./getcallsoptions) + +##### Returns + +`Promise`\<`Call`[]\> + +#### Call Signature + +> **getCalls**(`options?`, `includeCosts?`, `limit?`): `Promise`\<`Call`[]\> + +Defined in: [src/weaveClient.ts:936](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L936) + +##### Parameters + +###### options? + +[`CallsFilter`](./callsfilter) + +###### includeCosts? + +`boolean` + +###### limit? + +`number` + +##### Returns + +`Promise`\<`Call`[]\> + +*** + +### getCallsIterator() + +#### Call Signature + +> **getCallsIterator**(`options?`, `includeCosts?`, `limit?`): `AsyncIterableIterator`\<[`CallSchema`](./callschema)\> + +Defined in: [src/weaveClient.ts:957](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L957) + +##### Parameters + +###### options? + +[`CallsFilter`](./callsfilter) + +###### includeCosts? + +`boolean` + +###### limit? + +`number` + +##### Returns + +`AsyncIterableIterator`\<[`CallSchema`](./callschema)\> + +#### Call Signature + +> **getCallsIterator**(`options?`): `AsyncIterableIterator`\<[`CallSchema`](./callschema)\> + +Defined in: [src/weaveClient.ts:962](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L962) + +##### Parameters + +###### options? + +[`GetCallsOptions`](./getcallsoptions) + +##### Returns + +`AsyncIterableIterator`\<[`CallSchema`](./callschema)\> + +*** + +### getCallStack() + +> **getCallStack**(): `CallStack` + +Defined in: [src/weaveClient.ts:1482](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1482) + +#### Returns + +`CallStack` + +*** + +### getCurrentAttributes() + +> **getCurrentAttributes**(): `Record`\<`string`, `any`\> + +Defined in: [src/weaveClient.ts:1486](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1486) + +#### Returns + +`Record`\<`string`, `any`\> + +*** + +### linkPromptToRegistry() + +> **linkPromptToRegistry**(`prompt`, `options`): `Promise`\<`LinkAssetToRegistryRes`\> + +Link a published prompt version into a registry portfolio. + +Defined in: [src/weaveClient.ts:1181](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1181) + +#### Parameters + +##### prompt + +`RegistryLinkable` + +##### options + +`LinkPromptToRegistryOptions` + +#### Returns + +`Promise`\<`LinkAssetToRegistryRes`\> + +*** + +### publish() + +> **publish**(`obj`, `objId?`): `Promise`\<[`ObjectRef`](../classes/objectref)\> + +Defined in: [src/weaveClient.ts:890](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L890) + +#### Parameters + +##### obj + +`any` + +##### objId? + +`string` + +#### Returns + +`Promise`\<[`ObjectRef`](../classes/objectref)\> + +*** + +### pushNewCall() + +> **pushNewCall**(): `object` + +Defined in: [src/weaveClient.ts:1490](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1490) + +#### Returns + +`object` + +##### currentCall + +> **currentCall**: `CallStackEntry` + +##### newStack + +> **newStack**: `CallStack` + +##### parentCall + +> `optional` **parentCall**: `CallStackEntry` + +*** + +### runWithAttributes() + +> **runWithAttributes**\<`T`\>(`attributes`, `fn`): `T` + +Defined in: [src/weaveClient.ts:1498](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1498) + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### attributes + +`Record`\<`string`, `any`\> + +##### fn + +() => `T` + +#### Returns + +`T` + +*** + +### runWithCallStack() + +> **runWithCallStack**\<`T`\>(`callStack`, `fn`): `T` + +Defined in: [src/weaveClient.ts:1494](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1494) + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callStack + +`CallStack` + +##### fn + +() => `T` + +#### Returns + +`T` + +*** + +### saveCallEnd() + +> **saveCallEnd**(`callEnd`): `void` + +Defined in: [src/weaveClient.ts:1477](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1477) + +#### Parameters + +##### callEnd + +`EndedCallSchemaForInsert` + +#### Returns + +`void` + +*** + +### saveCallStart() + +> **saveCallStart**(`callStart`): `void` + +Defined in: [src/weaveClient.ts:1472](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1472) + +#### Parameters + +##### callStart + +`StartedCallSchemaForInsert` + +#### Returns + +`void` + +*** + +### saveOp() + +> **saveOp**(`op`, `objId?`): `Promise`\<`OpRef`\> + +Defined in: [src/weaveClient.ts:1537](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1537) + +#### Parameters + +##### op + +[`Op`](../type-aliases/op)\<(...`args`) => `any`\> + +##### objId? + +`string` + +#### Returns + +`Promise`\<`OpRef`\> + +*** + +### searchAgents() + +> **searchAgents**(`options`): `Promise`\<[`Response`](../type-aliases/response)\<`SearchAgentsResult`\>\> + +Full-text search across agent messages in the project. Returns hits +grouped by conversation, with a preview of each matched message. + +`query` is the full-text search term. Pass an empty string to retrieve +all messages matching the structured filters (`agentName`, +`conversationId`, `traceId`) without text matching. Use `limit` / +`offset` to page through results. + +Defined in: [src/weaveClient.ts:730](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L730) + +#### Parameters + +##### options + +`SearchAgentsOptions` + +#### Returns + +`Promise`\<[`Response`](../type-aliases/response)\<`SearchAgentsResult`\>\> + +#### Example + +```ts twoslash +// @noErrors +const client = await weave.init('entity/project'); +const resp = await client.searchAgents({ + query: 'Liverpool', + agentName: 'Assistant', + limit: 20, +}); + +for (const conversation of resp.data.results ?? []) { + console.log(`${conversation.conversation_id} (${conversation.agent_name})`); + for (const match of conversation.matched_messages) { + console.log(` [${match.role}] ${match.content_preview}`); + } +} + +console.log(`total conversations: ${resp.data.total_conversations}`); +``` + +*** + +### serializeAudio() + +> **serializeAudio**(`data`, `audioType?`): `Promise`\<`SerializedFileBlob`\> + +Upload raw audio bytes to the Weave content store and return the +`CustomWeaveType` placeholder that can be embedded in a call output. + +Use this when building call outputs manually (e.g. via `saveCallEnd`) +where the automatic serialization pipeline from `finishCall` is not used. + +Defined in: [src/weaveClient.ts:1424](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1424) + +#### Parameters + +##### data + +`Buffer` + +Raw audio bytes (WAV for best browser compatibility) + +##### audioType? + +`"wav"` = `DEFAULT_AUDIO_TYPE` + +File format — currently only 'wav' is supported + +#### Returns + +`Promise`\<`SerializedFileBlob`\> + +*** + +### updateCall() + +> **updateCall**(`callId`, `displayName`): `Promise`\<`void`\> + +Defined in: [src/weaveClient.ts:1710](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L1710) + +#### Parameters + +##### callId + +`string` + +##### displayName + +`string` + +#### Returns + +`Promise`\<`void`\> + +*** + +### waitForBatchProcessing() + +> **waitForBatchProcessing**(): `Promise`\<`void`\> + +Defined in: [src/weaveClient.ts:801](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L801) + +#### Returns + +`Promise`\<`void`\> \ No newline at end of file diff --git a/weave/reference/typescript-sdk/interfaces/weaveimage.mdx b/weave/reference/typescript-sdk/interfaces/weaveimage.mdx index 5f5c318e3c..65f09ab41a 100644 --- a/weave/reference/typescript-sdk/interfaces/weaveimage.mdx +++ b/weave/reference/typescript-sdk/interfaces/weaveimage.mdx @@ -3,54 +3,40 @@ title: "WeaveImage" description: "TypeScript SDK reference" --- -## Hierarchy +Defined in: [src/media.ts:13](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L13) -- `WeaveImageInput` - - ↳ `WeaveImage` - -## Table of contents +## Extends -### Properties - -- [\_weaveType](./weaveimage#_weavetype) -- [data](./weaveimage#data) -- [imageType](./weaveimage#imagetype) +- `WeaveImageInput` ## Properties ### \_weaveType -• **\_weaveType**: ``"Image"`` - -#### Defined in +> **\_weaveType**: `"Image"` -[src/media.ts:14](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L14) +Defined in: [src/media.ts:14](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L14) -___ +*** ### data -• **data**: `Buffer`\<`ArrayBufferLike`\> +> **data**: `Buffer` -#### Inherited from - -WeaveImageInput.data +Defined in: [src/media.ts:9](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L9) -#### Defined in +#### Inherited from -[src/media.ts:9](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L9) +`WeaveImageInput.data` -___ +*** ### imageType -• `Optional` **imageType**: ``"png"`` +> `optional` **imageType**: `"png"` -#### Inherited from - -WeaveImageInput.imageType +Defined in: [src/media.ts:10](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L10) -#### Defined in +#### Inherited from -[src/media.ts:10](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/media.ts#L10) \ No newline at end of file +`WeaveImageInput.imageType` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/agent.mdx b/weave/reference/typescript-sdk/type-aliases/agent.mdx index 2bd51309fe..fae6e2b02c 100644 --- a/weave/reference/typescript-sdk/type-aliases/agent.mdx +++ b/weave/reference/typescript-sdk/type-aliases/agent.mdx @@ -3,12 +3,6 @@ title: "Agent" description: "TypeScript SDK reference" --- -# Agent +> **Agent** = `AgentSchema` -Ƭ **Agent**: `AgentSchema` - -#### Defined in - -[src/weaveClient.ts:105](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L105) - -___ +Defined in: [src/weaveClient.ts:105](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L105) diff --git a/weave/reference/typescript-sdk/type-aliases/agentmessage.mdx b/weave/reference/typescript-sdk/type-aliases/agentmessage.mdx index fbeb2a8cb7..15fac03c4a 100644 --- a/weave/reference/typescript-sdk/type-aliases/agentmessage.mdx +++ b/weave/reference/typescript-sdk/type-aliases/agentmessage.mdx @@ -3,12 +3,6 @@ title: "AgentMessage" description: "TypeScript SDK reference" --- -# AgentMessage +> **AgentMessage** = `AgentChatMessageSchema` -Ƭ **AgentMessage**: `AgentChatMessageSchema` - -#### Defined in - -[src/weaveClient.ts:107](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L107) - -___ +Defined in: [src/weaveClient.ts:107](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L107) diff --git a/weave/reference/typescript-sdk/type-aliases/agentspan.mdx b/weave/reference/typescript-sdk/type-aliases/agentspan.mdx index 9171736998..f6e66981ba 100644 --- a/weave/reference/typescript-sdk/type-aliases/agentspan.mdx +++ b/weave/reference/typescript-sdk/type-aliases/agentspan.mdx @@ -3,12 +3,6 @@ title: "AgentSpan" description: "TypeScript SDK reference" --- -# AgentSpan +> **AgentSpan** = `AgentSpanSchema` -Ƭ **AgentSpan**: `AgentSpanSchema` - -#### Defined in - -[src/weaveClient.ts:108](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L108) - -___ +Defined in: [src/weaveClient.ts:108](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L108) diff --git a/weave/reference/typescript-sdk/type-aliases/agentturn.mdx b/weave/reference/typescript-sdk/type-aliases/agentturn.mdx index 0764332882..553230f110 100644 --- a/weave/reference/typescript-sdk/type-aliases/agentturn.mdx +++ b/weave/reference/typescript-sdk/type-aliases/agentturn.mdx @@ -3,12 +3,6 @@ title: "AgentTurn" description: "TypeScript SDK reference" --- -# AgentTurn +> **AgentTurn** = `AgentTraceChatRes` -Ƭ **AgentTurn**: `AgentTraceChatRes` - -#### Defined in - -[src/weaveClient.ts:109](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L109) - -___ +Defined in: [src/weaveClient.ts:109](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L109) diff --git a/weave/reference/typescript-sdk/type-aliases/agentversion.mdx b/weave/reference/typescript-sdk/type-aliases/agentversion.mdx index 71740a0b85..dbb838436b 100644 --- a/weave/reference/typescript-sdk/type-aliases/agentversion.mdx +++ b/weave/reference/typescript-sdk/type-aliases/agentversion.mdx @@ -3,12 +3,6 @@ title: "AgentVersion" description: "TypeScript SDK reference" --- -# AgentVersion +> **AgentVersion** = `AgentVersionSchema` -Ƭ **AgentVersion**: `AgentVersionSchema` - -#### Defined in - -[src/weaveClient.ts:110](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L110) - -___ +Defined in: [src/weaveClient.ts:110](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L110) diff --git a/weave/reference/typescript-sdk/type-aliases/getagentspansresult.mdx b/weave/reference/typescript-sdk/type-aliases/getagentspansresult.mdx index 65841cffce..ae551690d1 100644 --- a/weave/reference/typescript-sdk/type-aliases/getagentspansresult.mdx +++ b/weave/reference/typescript-sdk/type-aliases/getagentspansresult.mdx @@ -3,21 +3,24 @@ title: "GetAgentSpansResult" description: "TypeScript SDK reference" --- -# GetAgentSpansResult +> **GetAgentSpansResult** = `object` -Ƭ **GetAgentSpansResult**: `Object` +Result shape returned by [WeaveClient.getAgentSpans](../interfaces/weaveclient#getagentspans). -Result shape returned by [WeaveClient.getAgentSpans](../classes/weaveclient#getagentspans). +Defined in: [src/weaveClient.ts:183](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L183) -#### Type declaration +## Properties -| Name | Type | -| :------ | :------ | -| `spans` | [`AgentSpan`](./agentspan)[] | -| `total_count?` | `number` | +### spans -#### Defined in +> **spans**: [`AgentSpan`](./agentspan)[] -[src/weaveClient.ts:183](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L183) +Defined in: [src/weaveClient.ts:184](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L184) -___ +*** + +### total\_count + +> `optional` **total\_count**: `number` + +Defined in: [src/weaveClient.ts:185](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L185) diff --git a/weave/reference/typescript-sdk/type-aliases/getagentsresult.mdx b/weave/reference/typescript-sdk/type-aliases/getagentsresult.mdx index 3b6141113f..d524df6533 100644 --- a/weave/reference/typescript-sdk/type-aliases/getagentsresult.mdx +++ b/weave/reference/typescript-sdk/type-aliases/getagentsresult.mdx @@ -3,21 +3,24 @@ title: "GetAgentsResult" description: "TypeScript SDK reference" --- -# GetAgentsResult +> **GetAgentsResult** = `object` -Ƭ **GetAgentsResult**: `Object` +Result shape returned by [WeaveClient.getAgents](../interfaces/weaveclient#getagents). -Result shape returned by [WeaveClient.getAgents](../classes/weaveclient#getagents). +Defined in: [src/weaveClient.ts:125](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L125) -#### Type declaration +## Properties -| Name | Type | -| :------ | :------ | -| `agents` | [`Agent`](./agent)[] | -| `total_count?` | `number` | +### agents -#### Defined in +> **agents**: [`Agent`](./agent)[] -[src/weaveClient.ts:125](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L125) +Defined in: [src/weaveClient.ts:126](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L126) -___ +*** + +### total\_count + +> `optional` **total\_count**: `number` + +Defined in: [src/weaveClient.ts:127](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L127) diff --git a/weave/reference/typescript-sdk/type-aliases/getagentturnresult.mdx b/weave/reference/typescript-sdk/type-aliases/getagentturnresult.mdx index 27e17c8df4..d1ae240047 100644 --- a/weave/reference/typescript-sdk/type-aliases/getagentturnresult.mdx +++ b/weave/reference/typescript-sdk/type-aliases/getagentturnresult.mdx @@ -3,14 +3,8 @@ title: "GetAgentTurnResult" description: "TypeScript SDK reference" --- -# GetAgentTurnResult +> **GetAgentTurnResult** = [`AgentTurn`](./agentturn) -Ƭ **GetAgentTurnResult**: [`AgentTurn`](./agentturn) +Result shape returned by [WeaveClient.getAgentTurn](../interfaces/weaveclient#getagentturn). -Result shape returned by [WeaveClient.getAgentTurn](../classes/weaveclient#getagentturn). - -#### Defined in - -[src/weaveClient.ts:228](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L228) - -___ +Defined in: [src/weaveClient.ts:228](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L228) diff --git a/weave/reference/typescript-sdk/type-aliases/getagentturnsresult.mdx b/weave/reference/typescript-sdk/type-aliases/getagentturnsresult.mdx index 902a25ad06..8ca6e42177 100644 --- a/weave/reference/typescript-sdk/type-aliases/getagentturnsresult.mdx +++ b/weave/reference/typescript-sdk/type-aliases/getagentturnsresult.mdx @@ -3,26 +3,64 @@ title: "GetAgentTurnsResult" description: "TypeScript SDK reference" --- -# GetAgentTurnsResult +> **GetAgentTurnsResult** = `object` -Ƭ **GetAgentTurnsResult**: `Object` +Result shape returned by [WeaveClient.getAgentTurns](../interfaces/weaveclient#getagentturns). -Result shape returned by [WeaveClient.getAgentTurns](../classes/weaveclient#getagentturns). +Defined in: [src/weaveClient.ts:252](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L252) -#### Type declaration +## Properties -| Name | Type | -| :------ | :------ | -| `conversation_id` | `string` | -| `feedback?` | `Record`\<`string`, `any`\>[] \| ``null`` | -| `has_more?` | `boolean` | -| `limit?` | `number` | -| `offset?` | `number` | -| `total_turns?` | `number` | -| `turns?` | [`AgentTurn`](./agentturn)[] | +### conversation\_id -#### Defined in +> **conversation\_id**: `string` -[src/weaveClient.ts:252](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L252) +Defined in: [src/weaveClient.ts:253](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L253) -___ +*** + +### feedback + +> `optional` **feedback**: `Record`\<`string`, `any`\>[] \| `null` + +Defined in: [src/weaveClient.ts:259](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L259) + +*** + +### has\_more + +> `optional` **has\_more**: `boolean` + +Defined in: [src/weaveClient.ts:256](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L256) + +*** + +### limit + +> `optional` **limit**: `number` + +Defined in: [src/weaveClient.ts:257](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L257) + +*** + +### offset + +> `optional` **offset**: `number` + +Defined in: [src/weaveClient.ts:258](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L258) + +*** + +### total\_turns + +> `optional` **total\_turns**: `number` + +Defined in: [src/weaveClient.ts:255](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L255) + +*** + +### turns + +> `optional` **turns**: [`AgentTurn`](./agentturn)[] + +Defined in: [src/weaveClient.ts:254](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L254) diff --git a/weave/reference/typescript-sdk/type-aliases/getagentversionsresult.mdx b/weave/reference/typescript-sdk/type-aliases/getagentversionsresult.mdx index 7398af01f4..c4441b55b8 100644 --- a/weave/reference/typescript-sdk/type-aliases/getagentversionsresult.mdx +++ b/weave/reference/typescript-sdk/type-aliases/getagentversionsresult.mdx @@ -3,21 +3,24 @@ title: "GetAgentVersionsResult" description: "TypeScript SDK reference" --- -# GetAgentVersionsResult +> **GetAgentVersionsResult** = `object` -Ƭ **GetAgentVersionsResult**: `Object` +Result shape returned by [WeaveClient.getAgentVersions](../interfaces/weaveclient#getagentversions). -Result shape returned by [WeaveClient.getAgentVersions](../classes/weaveclient#getagentversions). +Defined in: [src/weaveClient.ts:152](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L152) -#### Type declaration +## Properties -| Name | Type | -| :------ | :------ | -| `total_count?` | `number` | -| `versions` | [`AgentVersion`](./agentversion)[] | +### total\_count -#### Defined in +> `optional` **total\_count**: `number` -[src/weaveClient.ts:152](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L152) +Defined in: [src/weaveClient.ts:154](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L154) -___ +*** + +### versions + +> **versions**: [`AgentVersion`](./agentversion)[] + +Defined in: [src/weaveClient.ts:153](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L153) diff --git a/weave/reference/typescript-sdk/type-aliases/messagepart.mdx b/weave/reference/typescript-sdk/type-aliases/messagepart.mdx index 222ef9efeb..46dc11c72d 100644 --- a/weave/reference/typescript-sdk/type-aliases/messagepart.mdx +++ b/weave/reference/typescript-sdk/type-aliases/messagepart.mdx @@ -3,12 +3,6 @@ title: "MessagePart" description: "TypeScript SDK reference" --- -# MessagePart +> **MessagePart** = \{ `content`: `string`; `type`: `"text"`; \} \| \{ `content`: `string`; `type`: `"reasoning"`; \} \| \{ `arguments?`: `string`; `toolCallId`: `string`; `toolName`: `string`; `type`: `"tool_call"`; \} \| \{ `result?`: `string`; `toolCallId`: `string`; `type`: `"tool_result"`; \} \| \{ `fileId`: `string`; `mimeType?`: `string`; `modality`: [`Modality`](./modality); `type`: `"file"`; \} \| \{ `content`: `string`; `mimeType`: `string`; `modality`: [`Modality`](./modality); `type`: `"blob"`; \} \| \{ `modality`: [`Modality`](./modality); `type`: `"uri"`; `uri`: `string`; \} -Ƭ **MessagePart**: \{ `content`: `string` ; `type`: ``"text"`` } \| \{ `content`: `string` ; `type`: ``"reasoning"`` } \| \{ `arguments?`: `string` ; `toolCallId`: `string` ; `toolName`: `string` ; `type`: ``"tool_call"`` } \| \{ `result?`: `string` ; `toolCallId`: `string` ; `type`: ``"tool_result"`` } \| \{ `fileId`: `string` ; `mimeType?`: `string` ; `modality`: [`Modality`](./modality) ; `type`: ``"file"`` } \| \{ `content`: `string` ; `mimeType`: `string` ; `modality`: [`Modality`](./modality) ; `type`: ``"blob"`` } \| \{ `modality`: [`Modality`](./modality) ; `type`: ``"uri"`` ; `uri`: `string` } - -#### Defined in - -[src/genai/types.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L23) - -___ +Defined in: [src/genai/types.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L23) diff --git a/weave/reference/typescript-sdk/type-aliases/modality.mdx b/weave/reference/typescript-sdk/type-aliases/modality.mdx index 7aadb0f160..b170a84047 100644 --- a/weave/reference/typescript-sdk/type-aliases/modality.mdx +++ b/weave/reference/typescript-sdk/type-aliases/modality.mdx @@ -3,12 +3,6 @@ title: "Modality" description: "TypeScript SDK reference" --- -# Modality +> **Modality** = `"image"` \| `"audio"` \| `"video"` \| `"document"` -Ƭ **Modality**: ``"image"`` \| ``"audio"`` \| ``"video"`` \| ``"document"`` - -#### Defined in - -[src/genai/types.ts:13](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L13) - -___ +Defined in: [src/genai/types.ts:13](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L13) diff --git a/weave/reference/typescript-sdk/type-aliases/op.mdx b/weave/reference/typescript-sdk/type-aliases/op.mdx index c15fab4a15..ca3c238480 100644 --- a/weave/reference/typescript-sdk/type-aliases/op.mdx +++ b/weave/reference/typescript-sdk/type-aliases/op.mdx @@ -1,20 +1,44 @@ --- -title: "Op" +title: "Op" description: "TypeScript SDK reference" --- -# Op +> **Op**\<`T`\> = `object` & `T` & (...`args`) => `ReturnType`\<`T`\> *extends* `AsyncIterable`\ ? `AsyncIterable`\<`Awaited`\<`U`\>\> : `Promise`\<`Awaited`\<`ReturnType`\<`T`\>\>\> -Ƭ **Op**\<`T`\>: \{ `__boundThis?`: [`WeaveObject`](../classes/weaveobject) ; `__isOp`: ``true`` ; `__name`: `string` ; `__parameterNames?`: `ParameterNamesOption` ; `__savedRef?`: `OpRef` \| `Promise`\<`OpRef`\> ; `__wrappedFunction`: `T` ; `invoke`: `CallMethod`\<`T`\> } & `T` & (...`args`: `Parameters`\<`T`\>) => `ReturnType`\<`T`\> extends `AsyncIterable`\ ? `AsyncIterable`\<`Awaited`\<`U`\>\> : `Promise`\<`Awaited`\<`ReturnType`\<`T`\>\>\> +Defined in: [src/opType.ts:7](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/opType.ts#L7) -#### Type parameters +## Type Declaration -| Name | Type | -| :------ | :------ | -| `T` | extends (...`args`: `any`[]) => `any` | +### \_\_boundThis -#### Defined in +> `optional` **\_\_boundThis**: [`WeaveObject`](../classes/weaveobject) -[src/opType.ts:7](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/opType.ts#L7) +### \_\_isOp -___ +> **\_\_isOp**: `true` + +### \_\_name + +> **\_\_name**: `string` + +### \_\_parameterNames + +> `optional` **\_\_parameterNames**: `ParameterNamesOption` + +### \_\_savedRef + +> `optional` **\_\_savedRef**: `OpRef` \| `Promise`\<`OpRef`\> + +### \_\_wrappedFunction + +> **\_\_wrappedFunction**: `T` + +### invoke + +> **invoke**: `CallMethod`\<`T`\> + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `any` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/opdecorator.mdx b/weave/reference/typescript-sdk/type-aliases/opdecorator.mdx index 50f13b604d..63c3a7292c 100644 --- a/weave/reference/typescript-sdk/type-aliases/opdecorator.mdx +++ b/weave/reference/typescript-sdk/type-aliases/opdecorator.mdx @@ -1,11 +1,9 @@ --- -title: "OpDecorator" +title: "OpDecorator" description: "TypeScript SDK reference" --- -# OpDecorator - -Ƭ **OpDecorator**\<`T`\>: (`value`: `T`, `context`: `ClassMethodDecoratorContext`) => `T` \| `void` & (`target`: `object`, `propertyKey`: `string` \| `symbol`, `descriptor`: `TypedPropertyDescriptor`\<`T`\>) => `TypedPropertyDescriptor`\<`T`\> \| `void` +> **OpDecorator**\<`T`\> = (`value`, `context`) => `T` \| `void` & (`target`, `propertyKey`, `descriptor`) => `TypedPropertyDescriptor`\<`T`\> \| `void` Helper type for decorators This represents a decorator function that can be used with both legacy and Stage 3 decorators. @@ -19,14 +17,10 @@ For legacy decorators: propertyKey: The method name descriptor: The property descriptor containing the method -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | extends (...`args`: `any`[]) => `any` | +Defined in: [src/opType.ts:41](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/opType.ts#L41) -#### Defined in +## Type Parameters -[src/opType.ts:41](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/opType.ts#L41) +### T -___ +`T` *extends* (...`args`) => `any` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/response.mdx b/weave/reference/typescript-sdk/type-aliases/response.mdx index 4b724dcd90..15153089bb 100644 --- a/weave/reference/typescript-sdk/type-aliases/response.mdx +++ b/weave/reference/typescript-sdk/type-aliases/response.mdx @@ -1,20 +1,14 @@ --- -title: "Response" +title: "Response" description: "TypeScript SDK reference" --- -# Response +> **Response**\<`T`\> = [`HttpResponse`](../interfaces/httpresponse)\<`T`, [`HTTPValidationError`](../interfaces/httpvalidationerror)\> -Ƭ **Response**\<`T`\>: [`HttpResponse`](../interfaces/httpresponse)\<`T`, [`HTTPValidationError`](../interfaces/httpvalidationerror)\> +Defined in: [src/weaveClient.ts:65](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L65) -#### Type parameters +## Type Parameters -| Name | -| :------ | -| `T` | +### T -#### Defined in - -[src/weaveClient.ts:65](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/weaveClient.ts#L65) - -___ +`T` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/role.mdx b/weave/reference/typescript-sdk/type-aliases/role.mdx index 22e4638bb0..80d044d8dc 100644 --- a/weave/reference/typescript-sdk/type-aliases/role.mdx +++ b/weave/reference/typescript-sdk/type-aliases/role.mdx @@ -3,14 +3,8 @@ title: "Role" description: "TypeScript SDK reference" --- -# Role - -Ƭ **Role**: ``"user"`` \| ``"assistant"`` \| ``"system"`` \| ``"tool"`` \| ``"developer"`` \| ``"function"`` +> **Role** = `"user"` \| `"assistant"` \| `"system"` \| `"tool"` \| `"developer"` \| `"function"` Public data types for the Weave GenAI conversation SDK. -#### Defined in - -[src/genai/types.ts:5](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L5) - -___ +Defined in: [src/genai/types.ts:5](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/types.ts#L5) diff --git a/weave/reference/typescript-sdk/type-aliases/session-1.mdx b/weave/reference/typescript-sdk/type-aliases/session-1.mdx new file mode 100644 index 0000000000..57373596ee --- /dev/null +++ b/weave/reference/typescript-sdk/type-aliases/session-1.mdx @@ -0,0 +1,13 @@ +--- +title: "Session" +description: "TypeScript SDK reference" +--- + + + + **Deprecated.** Use [Conversation](../interfaces/conversation) instead. + + +> **Session** = [`Conversation`](../interfaces/conversation) + +Defined in: [src/genai/conversation.ts:191](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L191) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/session.mdx b/weave/reference/typescript-sdk/type-aliases/session.mdx index 431ddd646f..6f9a1fb9a0 100644 --- a/weave/reference/typescript-sdk/type-aliases/session.mdx +++ b/weave/reference/typescript-sdk/type-aliases/session.mdx @@ -3,18 +3,11 @@ title: "Session" description: "TypeScript SDK reference" --- -# Session - **Deprecated.** Use [Conversation](../classes/conversation) instead. + **Deprecated.** Use [Conversation](../interfaces/conversation) instead. -Ƭ **Session**: [`Conversation`](../classes/conversation) +> **Session** = *typeof* [`Conversation`](../interfaces/conversation) -#### Defined in - -[src/genai/conversation.ts:191](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L191) - -[src/genai/conversation.ts:193](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L193) - -___ +Defined in: [src/genai/conversation.ts:191](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L191) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/sessioninit.mdx b/weave/reference/typescript-sdk/type-aliases/sessioninit.mdx index 05654ff3ef..5e10b4aec1 100644 --- a/weave/reference/typescript-sdk/type-aliases/sessioninit.mdx +++ b/weave/reference/typescript-sdk/type-aliases/sessioninit.mdx @@ -3,16 +3,11 @@ title: "SessionInit" description: "TypeScript SDK reference" --- -# SessionInit **Deprecated.** Use [ConversationInit](../interfaces/conversationinit) instead. -Ƭ **SessionInit**: [`ConversationInit`](../interfaces/conversationinit) +> **SessionInit** = [`ConversationInit`](../interfaces/conversationinit) -#### Defined in - -[src/genai/conversation.ts:189](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L189) - -___ +Defined in: [src/genai/conversation.ts:189](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/conversation.ts#L189) \ No newline at end of file diff --git a/weave/reference/typescript-sdk/type-aliases/settings.mdx b/weave/reference/typescript-sdk/type-aliases/settings.mdx index 6b5aa89261..6354c4a1e2 100644 --- a/weave/reference/typescript-sdk/type-aliases/settings.mdx +++ b/weave/reference/typescript-sdk/type-aliases/settings.mdx @@ -3,23 +3,73 @@ title: "Settings" description: "TypeScript SDK reference" --- -# Settings +> **Settings** = `object` -Ƭ **Settings**: `Object` +Defined in: [src/settings.ts:3](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/settings.ts#L3) -#### Type declaration +## Properties -| Name | Type | Description | -| :------ | :------ | :------ | -| `attributes` | `Record`\<`string`, `any`\> | A map of attributes applied to every trace produced by this client. | -| `genai` | \{ `batchOptions?`: `BufferConfig` ; `spanProcessor?`: ``"batch"`` \| ``"simple"`` \| `SpanProcessor` } | - | -| `genai.batchOptions?` | `BufferConfig` | `BatchSpanProcessor` configuration. Ignored unless `spanProcessor === 'batch'`. | -| `genai.spanProcessor?` | ``"batch"`` \| ``"simple"`` \| `SpanProcessor` | How GenAI spans are exported. - `'batch'` (default): `BatchSpanProcessor`, suitable for production agents and long-lived processes. - `'simple'`: `SimpleSpanProcessor`, one HTTP POST per span. Useful for tests and short-lived CLIs where deterministic flush matters more than throughput. - `SpanProcessor` instance: a user-supplied processor. The caller owns its lifecycle; the Weave OTLP exporter targeting `/agents/otel/v1/traces` is not used. | -| `printCallLink` | `boolean` | Prints links in terminal to Weave UI for ops. `Default` `true` | -| `useOTelV2` | `boolean` | Routes OTel-capable integrations through their OTel variant. `Default` `true` | +### attributes -#### Defined in +> `readonly` **attributes**: `Record`\<`string`, `any`\> -[src/settings.ts:3](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/settings.ts#L3) +A map of attributes applied to every trace produced by this client. -## Variables +Defined in: [src/settings.ts:14](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/settings.ts#L14) + +*** + +### genai + +> `readonly` **genai**: `object` + +Defined in: [src/settings.ts:23](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/settings.ts#L23) + +#### batchOptions + +> `optional` **batchOptions**: `BufferConfig` + +`BatchSpanProcessor` configuration. Ignored unless `spanProcessor === 'batch'`. + +#### spanProcessor + +> `optional` **spanProcessor**: `"batch"` \| `"simple"` \| `SpanProcessor` + +How GenAI spans are exported. + +- `'batch'` (default): `BatchSpanProcessor`, suitable for production + agents and long-lived processes. +- `'simple'`: `SimpleSpanProcessor`, one HTTP POST per span. Useful for + tests and short-lived CLIs where deterministic flush matters more than + throughput. +- `SpanProcessor` instance: a user-supplied processor. The caller owns + its lifecycle; the Weave OTLP exporter targeting `/agents/otel/v1/traces` + is not used. + +*** + +### printCallLink + +> `readonly` **printCallLink**: `boolean` + +Prints links in terminal to Weave UI for ops. + +Defined in: [src/settings.ts:9](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/settings.ts#L9) + +#### Default + +`true` + +*** + +### useOTelV2 + +> **useOTelV2**: `boolean` + +Routes OTel-capable integrations through their OTel variant. + +Defined in: [src/settings.ts:21](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/settings.ts#L21) + +#### Default + +`true` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/variables/endsession.mdx b/weave/reference/typescript-sdk/variables/endsession.mdx new file mode 100644 index 0000000000..97b607da2e --- /dev/null +++ b/weave/reference/typescript-sdk/variables/endsession.mdx @@ -0,0 +1,37 @@ +--- +title: "endSession" +description: "TypeScript SDK reference" +--- + + + + **Deprecated.** Use [endConversation](../functions/endconversation) instead. + + +> `const` **endSession**: (`opts?`) => `void` = `endConversation` + +End the current Conversation. No-op if no Conversation is active. + +Defined in: [src/genai/api.ts:169](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L169) + +## Parameters + +### opts? + +`SpanEndOptions` + +## Returns + +`void` + +## Examples + +```ts twoslash +// @noErrors +weave.endConversation(); +``` + +```ts twoslash +// @noErrors +weave.endConversation({endTime: new Date('2026-05-29T10:00:01.700Z')}); +``` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/variables/getcurrentsession.mdx b/weave/reference/typescript-sdk/variables/getcurrentsession.mdx new file mode 100644 index 0000000000..c79635aed0 --- /dev/null +++ b/weave/reference/typescript-sdk/variables/getcurrentsession.mdx @@ -0,0 +1,19 @@ +--- +title: "getCurrentSession" +description: "TypeScript SDK reference" +--- + + + + **Deprecated.** Use [getCurrentConversation](../functions/getcurrentconversation) instead. + + +> `const` **getCurrentSession**: () => [`Conversation`](../interfaces/conversation) \| `undefined` = `getCurrentConversation` + +Returns the current Conversation, or undefined. + +Defined in: [src/genai/context.ts:64](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/context.ts#L64) + +## Returns + +[`Conversation`](../interfaces/conversation) \| `undefined` \ No newline at end of file diff --git a/weave/reference/typescript-sdk/variables/startsession.mdx b/weave/reference/typescript-sdk/variables/startsession.mdx new file mode 100644 index 0000000000..46e7af92ad --- /dev/null +++ b/weave/reference/typescript-sdk/variables/startsession.mdx @@ -0,0 +1,45 @@ +--- +title: "startSession" +description: "TypeScript SDK reference" +--- + + + + **Deprecated.** Use [startConversation](../functions/startconversation) instead. + + +> `const` **startSession**: (`opts`) => [`Conversation`](../interfaces/conversation) = `startConversation` + +Start a new Conversation and install it as the current conversation. +Subsequent calls to `startTurn` will pick it up automatically. + +Pass `attributes` to stamp custom (non-semconv) attributes on every +span the conversation emits. + +Defined in: [src/genai/api.ts:33](https://github.com/wandb/weave/blob/8c5f077eb11c42b84000726ff20504abc728d3fb/sdks/node/src/genai/api.ts#L33) + +## Parameters + +### opts? + +[`ConversationInit`](../interfaces/conversationinit) = `{}` + +## Returns + +[`Conversation`](../interfaces/conversation) + +## Examples + +```ts twoslash +// @noErrors +weave.startConversation({agentName: 'research-bot'}); +``` + +```ts twoslash +// @noErrors +weave.startConversation({ + agentName: 'research-bot', + conversationId: '019efa53-8a65-711c-b4c1-7c1cb72c0bb7', + attributes: {'myagent.version': '1.23'}, +}); +``` \ No newline at end of file