langchain-ai / langsmith-sdk

LangSmith Client SDK Implementations
https://docs.smith.langchain.com/
MIT License
403 stars 75 forks source link

Issue: `runTools` is not a function #1102

Open jmoseley opened 1 week ago

jmoseley commented 1 week ago

Issue you'd like to raise.

For the JS SDK, I believe that the wrapOpenAI helper is failing to expose anything except parse on the beta chat completions resource.

The problem may have been introduced in this change, as it only happens after version 0.1.62.

This crops up as this error:

TypeError: openai.beta.chat.completions.runTools is not a function

I logged the resources and noticed that openai.beta.chat.completions is an object that only has parse as a member.

// console.log('wat', { openai, "oepnai.beta": openai?.beta, "openai.beta.chat": openai?.beta?.chat, "openai.beta.chat.completions": openai?.beta?.chat?.completions, "openai.beta.chat.completions.runTools": openai?.beta?.chat?.completions?.runTools })

wat {
  openai: {
    baseURL: 'https://api.openai.com/v1',
    maxRetries: 2,
    timeout: 600000,
    httpAgent: undefined,
    fetch: <ref *1> [Function: fetch] {
      isRedirect: [Function (anonymous)],
      Promise: [Function: Promise],
      default: [Circular *1],
      Headers: [class Headers],
      Request: [class Request],
      Response: [class Response],
      FetchError: [Function: FetchError],
      AbortError: [Function: AbortError]
    },
    completions: { _client: [OpenAI], create: [Function: traceableFunc] },
    chat: { _client: [OpenAI], completions: [Object] },
    embeddings: Embeddings { _client: [OpenAI] },
    files: Files { _client: [OpenAI] },
    images: Images { _client: [OpenAI] },
    audio: Audio {
      _client: [OpenAI],
      transcriptions: [Transcriptions],
      translations: [Translations],
      speech: [Speech]
    },
    moderations: Moderations { _client: [OpenAI] },
    models: Models { _client: [OpenAI] },
    fineTuning: FineTuning { _client: [OpenAI], jobs: [Jobs] },
    beta: {
      _client: [OpenAI],
      vectorStores: [VectorStores],
      chat: [Object],
      assistants: [Assistants],
      threads: [Threads]
    },
    batches: Batches { _client: [OpenAI] },
    uploads: Uploads { _client: [OpenAI], parts: [Parts] },
    _options: {
      apiKey: '[secret]',
      organization: null,
      project: null,
      baseURL: 'https://api.openai.com/v1'
    },
    apiKey: '[secret]',
    organization: null,
    project: null
  },
  "openai.beta": {
    _client: OpenAI {
      baseURL: 'https://api.openai.com/v1',
      maxRetries: 2,
      timeout: 600000,
      httpAgent: undefined,
      fetch: [Function],
      completions: [Completions],
      chat: [Chat],
      embeddings: [Embeddings],
      files: [Files],
      images: [Images],
      audio: [Audio],
      moderations: [Moderations],
      models: [Models],
      fineTuning: [FineTuning],
      beta: [Beta],
      batches: [Batches],
      uploads: [Uploads],
      _options: [Object],
      apiKey: '[secret]',
      organization: null,
      project: null
    },
    vectorStores: VectorStores {
      _client: [OpenAI],
      files: [Files],
      fileBatches: [FileBatches]
    },
    chat: { _client: [OpenAI], completions: [Object] },
    assistants: Assistants { _client: [OpenAI] },
    threads: Threads { _client: [OpenAI], runs: [Runs], messages: [Messages] }
  },
  "openai.beta.chat": {
    _client: OpenAI {
      baseURL: 'https://api.openai.com/v1',
      maxRetries: 2,
      timeout: 600000,
      httpAgent: undefined,
      fetch: [Function],
      completions: [Completions],
      chat: [Chat],
      embeddings: [Embeddings],
      files: [Files],
      images: [Images],
      audio: [Audio],
      moderations: [Moderations],
      models: [Models],
      fineTuning: [FineTuning],
      beta: [Beta],
      batches: [Batches],
      uploads: [Uploads],
      _options: [Object],
      apiKey: '[secret]',
      organization: null,
      project: null
    },
    completions: { _client: [OpenAI], parse: [Function: traceableFunc] }
  },
  "openai.beta.chat.completions": {
    _client: OpenAI {
      baseURL: 'https://api.openai.com/v1',
      maxRetries: 2,
      timeout: 600000,
      httpAgent: undefined,
      fetch: [Function],
      completions: [Completions],
      chat: [Chat],
      embeddings: [Embeddings],
      files: [Files],
      images: [Images],
      audio: [Audio],
      moderations: [Moderations],
      models: [Models],
      fineTuning: [FineTuning],
      beta: [Beta],
      batches: [Batches],
      uploads: [Uploads],
      _options: [Object],
      apiKey: '[secret]',
      organization: null,
      project: null
    },
    parse: [Function: traceableFunc]
  },
  "openai.beta.chat.completions.runTools": undefined
}

Suggestion:

No response

jacoblee93 commented 1 week ago

Hey @jmoseley, having a look at this! Thanks for reporting!

chulanpro5 commented 1 week ago

I tried downgrading to langsmith@0.1.62, and it worked!