Skip to content

Conversation

@Soufiane-Ra
Copy link

To use with Langchain / OpenAI add extra_body={"schema": yourSchema} or extra_body={"regex": yourRegex} example:

llm = ChatOpenAI ( openai_api_key="EMPTY",
                   openai_api_base="http://localhost:8000/v1",
                   model_name=model_path,
                   extra_body={"schema": json_schema },
                 )

@lapp0
Copy link
Contributor

lapp0 commented Jan 29, 2024

Thanks for the PR! I see two issues this would close

#512

#594

Copy link
Contributor

@lapp0 lapp0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job integrating vllms openai module with outlines!

Could you document usage and availability in vllm.md (or a new markdown file openai_endpoint.md)?

I'll do thorough smoke testing later this week.

from http import HTTPStatus
from typing import AsyncGenerator, Dict, List, Optional, Tuple, Union

from aioprometheus import MetricsMiddleware
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure any new dependencies are added are part of pyproject.toml

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't they be installed when installing vLLM?

Copy link
Contributor

@lapp0 lapp0 Feb 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I should have pulled before comparing to my local openai_server.py...

best_of=request.best_of,
top_k=request.top_k,
ignore_eos=request.ignore_eos,
use_beam_search=request.use_beam_search,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beam search functionality depends on #539

@jamestwhedbee
Copy link

I'd expect this to extend OpenAI's existing response_format field to include the schema, rather than use an extra_body field. Thoughts?

@rlouf
Copy link
Member

rlouf commented Feb 1, 2024

Thank you for opening a PR, this is impressive and I will need a few days to review it. In the meantime please make sure that the checks in the CI are passing.

@7flash
Copy link
Contributor

7flash commented Feb 1, 2024

Wow looks amazing, so I understand now after I deploy outlines to my server, then I can just add another line into my litellm config pointing to outlines, and then it just works compatible with my existing UI?

@rlouf rlouf added structured generation Linked to structured generation vLLM Things involving vLLM support labels Feb 5, 2024
@lapp0
Copy link
Contributor

lapp0 commented Feb 5, 2024

I tried smoke testing, but got

  File "/root/outlines/outlines/serve/openai_server.py", line 86
    parser.add_argument(
IndentationError: unexpected indent

@7flash 7flash mentioned this pull request Feb 6, 2024
@rlouf
Copy link
Member

rlouf commented Feb 6, 2024

@Soufiane-Ra could you solve the formatting issues?

return StreamingResponse(
completion_stream_generator(), media_type="text/event-stream"
)
else:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Soufiane-Ra Great work! We'd love to use this. It looks like there is another indentation error here. Could you fix it? Thx

@findalexli
Copy link

Following this and would love to see any update

@olaf-beh
Copy link

olaf-beh commented Mar 4, 2024

I'd expect this to extend OpenAI's existing response_format field to include the schema, rather than use an extra_body field. Thoughts?

I cannot agree. To be openai compatible we have to use extra_body. They specified extra_body field exactly for the use case to pass custom application fields.

E.g. if you use openai library for sending requests to vllm.engine.openai.entrypoints.openai.apiserver and you use an extra JSON field which is not specified by official openai API, then the openai python library will raise an error (I tried that a couple of weeks ago).

Just my two cents ...

Just saw this PR in vLLM: vllm-project/vllm#3211
It integrates oulines in vllm.engine.openai.entrypoints.openai.apiserver. This solves this PR, doesn't it?

@rlouf
Copy link
Member

rlouf commented Mar 7, 2024

Thank you for contributing! In the meantime vLLM integrated Outlines, and you can now use structured generation directly from there.

@rlouf rlouf closed this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

structured generation Linked to structured generation vLLM Things involving vLLM support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose OpenAI API with CFG vLLM OpenAI compatible server integration

8 participants