Code Monkey home page Code Monkey logo

Comments (5)

Vinlic avatar Vinlic commented on May 23, 2024

请将文件编码为base64提供在url位置,base64前面还需要提供数据头,比如上传jpg文件需要这样提供:
"url": "data:image/jpeg;base64,/9j/4AAQSkZJRgA..."
@332123342

from qwen-free-api.

332123342 avatar 332123342 commented on May 23, 2024

目前的想到的办法是把本地文件先上传到github上,再去到url。。。

from qwen-free-api.

332123342 avatar 332123342 commented on May 23, 2024

请将文件编码为base64提供在url位置,base64前面还需要提供数据头,比如上传jpg文件需要这样提供: "url": "data:image/jpeg;base64,/9j/4AAQSkZJRgA..." @332123342

文件大小有几兆,这样有问题吗?

from qwen-free-api.

Vinlic avatar Vinlic commented on May 23, 2024

@332123342 没问题的,十几M的也传过

from qwen-free-api.

332123342 avatar 332123342 commented on May 23, 2024

@Vinlic

response = client.chat.completions.create(
    model="qwen",
    messages = [
        {
            "role": "user",
            "content": [
                {
                    "type": "file",
                    "file_url": {
                        "url": "data:text/plain;base64,aSBhbSBhIGdvb2QgYm95"
                    }
                },
                {
                    "type": "text",
                    "text": "上传的文档说了什么"
                }
            ]
        }
    ],
)

这样可以了,感谢🙏

update:
用base64上传的文档长度太长还是会报错。。。
image

from qwen-free-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.