-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
268 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
from abc import ABC, abstractmethod | ||
from typing import Generic, TypeVar | ||
|
||
from .dataset import BaseDataset | ||
from typing import Any, Generator, Generic, TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
|
||
class BaseGenerator(Generic[T], ABC): | ||
@abstractmethod | ||
def generate_dataset(self) -> BaseDataset[T]: | ||
def generate(self) -> Generator[T, Any, None]: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,14 @@ | ||
import sys | ||
from dataclasses import dataclass, field | ||
from typing import IO | ||
|
||
from ..core import BasePromptValue, BaseTarget, Response | ||
|
||
|
||
@dataclass | ||
class StdOutTarget(BaseTarget): | ||
def __init__( | ||
self, | ||
*, | ||
text_stream: IO[str] = sys.stdout, | ||
) -> None: | ||
self._text_stream = text_stream | ||
text_stream: IO[str] = field(default=sys.stdout) | ||
|
||
def send_prompt(self, prompt: BasePromptValue) -> Response: | ||
self._text_stream.write(f"{prompt.to_string()}\n") | ||
return Response(content=f"Prompt printed to stream {self._text_stream.name}.") | ||
self.text_stream.write(f"{prompt.to_string()}\n") | ||
return Response(content=f"Prompt printed to stream {self.text_stream.name}.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.