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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAI LLM Generators for Haystack 2.0 #5623

Closed
Tracked by #5330
ZanSara opened this issue Aug 25, 2023 · 0 comments · Fixed by #5744
Closed
Tracked by #5330

OpenAI LLM Generators for Haystack 2.0 #5623

ZanSara opened this issue Aug 25, 2023 · 0 comments · Fixed by #5744
Assignees
Labels
2.x Related to Haystack v2.0
Milestone

Comments

@ZanSara
Copy link
Contributor

ZanSara commented Aug 25, 2023

See the proposal: #5540


OpenAI chat models like ChatGPT and GPT4 can be queried through an identical API, therefore we will have a single component for both GPT4 and ChatGPT.

We can either call it OpenAIGenerator and make it support also GPT3 models, or call it GPT4Generator and make an alias for it called ChatGPTGenerator.

Draft API for GPT4Generator:

@component
class GPT4Generator:

    def __init__(self, streaming_callback: Optional[Callable] = None, ... gpt3.5/4 parameters ...):
        ...

    @component.output_types(replies=List[List[str]])
    def run(self, prompts: List[str], ... chatgpt specific params...):
        ...
        return {'replies': [...], 'metadata': [...]}

Note how the component takes a list of prompts and LLM parameters only, but no variables nor templates, and returns only strings. This is because input rendering and output parsing are delegated to PromptBuilder.

In order to support token streaming, we make this component accept a callback in __init__, and that callback will be called every time a new chunk of the streamed response is received.

@ZanSara ZanSara changed the title GPT4Generator (and ChatGPTGenerator) OpenAI LLM Generators for Haystack 2.0 Aug 25, 2023
@ZanSara ZanSara added the 2.x Related to Haystack v2.0 label Aug 25, 2023
@ZanSara ZanSara assigned julian-risch and ZanSara and unassigned julian-risch Aug 28, 2023
@Timoeller Timoeller added this to the 2.0-beta milestone Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Related to Haystack v2.0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants