Rodrigo Rubio
Rodrigo Rubio

Reputation: 1760

OpenAi Fine Tuned model not found 404 - using js-langchain

I've successfully created a fine tuned model and is avialable under openai's playground, this is great. However, when trying to call it from my nodejs app using langchainJS, i'm getting a 404 not found.

Please note, code works fine when using 'gpt-3.5-turbo' model.

Calling it directly form the CLI works fine -

openai api completions.create -m <FINE_TUNED_MODEL> -p <YOUR_PROMPT>

The API being called is -

https://api.openai.com/v1/chat/completions

Invocation is as followed -

    const chat = new ChatOpenAI({
        modelName: <FINE_TUNED_MODEL>,
        openAIApiKey: openAIKey,        
    });

    const vectorStore = await SupabaseVectorStore.fromExistingIndex(
        new OpenAIEmbeddings(),
        {
            client,
            tableName: "documents",
            queryName: "match_documents",
        }
    );

    let chain = ConversationalRetrievalQAChain.fromLLM(
        chat,
        vectorStore.asRetriever(),
        { returnSourceDocuments: true }
    );

Any ideas on what could be going wrong?

Upvotes: 0

Views: 440

Answers (1)

Matthabbey
Matthabbey

Reputation: 31

There are a couple of discrepancies with your understanding of fine tuned models:

As of now fine-tuned models can only be accessed through the completions endpoint 17 not the Chat Completions endpoint 6. Use fine_tuned_model not id to consume your fine-tuned model. e.g.

"fine_tuned_model": "curie:ft-acmeco-2021-03-03-21-44-20" "id": "ft-AF1WoRqd3aJAHsqc9NY7iL8F" Read API reference for fine-tunes 20 to know more.

You can use retrieve fine tune request to have detailed information about the fine-tune job id where you’ll find the corresponding fine_tuned_model.

Upvotes: 0

Related Questions