Skip to content

Custom openai like sever nolonger work for new openai api #916

Closed as not planned
@OpenJarvisAI

Description

@OpenJarvisAI

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

I have acustomedz openai like server

@app.post("/v1/chat/completions", response_model=ChatCompletionResponse)
async def create_chat_completion(request: ChatCompletionRequest):
    print('got request')

This works for old openai,

but after upgrade, my custom server no longer receive the request now.

To Reproduce

my request code:

import openai
import argparse
from openai import OpenAI

parser = argparse.ArgumentParser()
parser.add_argument("--ip", type=str, default='127.0.0.1')
parser.add_argument("--port", type=str, default=80)
args = parser.parse_args()

local_ip = args.ip

base_url = 'http://127.0.0.1:8080'
model = "qwen-v2"

tts = False
stream_mode = True

if tts:
    client = OpenAI(api_key=api_key)
    response = client.audio.speech.create(
        model='tts-1', # "tts-1","tts-1-hd"
        voice='fable', # 'alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'
        input='hell,你好,请你介绍一下你自己',
    )
else:
    client = OpenAI(api_key='sk34fgerg', base_url=base_url)
    if stream_mode:
        questions = [
        '你好,请介绍一下你自己,以及北京的有哪些小吃。',
        '你是谁',
        '请列举出8部好看的电影'
        ]
        for qs in questions:
            print(f'问: {qs}')
            response = client.chat.completions.create(
                model="qwen-v2",
                messages=[
                    {"role": "user", "content": qs}
                ],
                temperature=0.95,
                stream=True
            )
            for chunk in response:
                if hasattr(chunk.choices[0].delta, "content"):
                    print(chunk.choices[0].delta.content, end="", flush=True)
                print()
    else:
        pass

Code snippets

No response

OS

macOS

Python version

3.10

Library version

1.3.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions