Skip to content

Upload file need the custom purpose support #397

@BenLampson

Description

@BenLampson

Confirm this is a feature request for the .NET library and not the underlying OpenAI API

  • This is a feature request for the .NET library

Describe the feature or improvement you are requesting

There's code below

  var fileClient = new OpenAIFileClient(new System.ClientModel.ApiKeyCredential("sk-xxxx"),
               new OpenAI.OpenAIClientOptions()
               {
                   Endpoint = new Uri("xxxx")
               });
  using var fs1 = File.OpenRead(@"D:\AITestTmpData\1.pdf"); 
  var res = fileClient.UploadFile(fs1, "1.pdf", purpose: "file-extract");

The question is whether Aliyun's service has a custom purpose key. So I can't use.

But Python's lib works fine with this code.
The code below is Aliyun's demo code.

import os
from pathlib import Path
from openai import OpenAI

client = OpenAI(
    # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

# test.txt 是一个本地示例文件
file_object = client.files.create(file=Path("test.txt"), purpose="file-extract")

print(file_object.model_dump_json())

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-author-feedbackWorkflow: More information is needed from author to address the issue.questionCategory: The issue is seeking information about the library or its usage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions