Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Stream JSON parser #625

Open
Undertone0809 opened this issue Apr 29, 2024 · 1 comment
Open

Add Stream JSON parser #625

Undertone0809 opened this issue Apr 29, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Undertone0809
Copy link
Owner

Undertone0809 commented Apr 29, 2024

馃殌 Feature Request

Currently, we cannot enable stream if setting output schema. Eg:

from typing import List
import promptulate as pne
from pydantic import BaseModel, Field


class LLMResponse(BaseModel):
    provinces: List[str] = Field(description="All provinces in China")


response: LLMResponse = pne.chat(
    messages="Please tell me all provinces in China.",
    output_schema=LLMResponse,
    model="gpt-4-1106-preview",
    stream=True,
)
print(response.provinces)

image

Need to build a json parser to parse stream type json data like this:

image

@Undertone0809 Undertone0809 added the enhancement New feature or request label Apr 29, 2024
@Undertone0809
Copy link
Owner Author

Undertone0809 commented Apr 29, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Ready
Development

No branches or pull requests

2 participants