Python
chaincrafter.catalogs
A catalog is a collection of chains and prompts stored in a YAML file.
Catalogload(path: str)get_chain(chain_id: str) -> Chainget_prompt(prompt_id: str, prompt_modifiers: [Callable] = [], **input_vars_transformers: [dict[str, Callable]]) -> Prompt__getitem__(prompt_id: str) -> Prompt
chaincrafter.chains
Chainrun(chat_model: ChatModel, starting_input_vars: dict) -> [Message]: Runs the chain given aChatModeland a set of starting input variables.async_run(chat_model: ChatModel, starting_input_vars: dict) -> [Message]: Runs the chain asynchronously usingasyncio, see Async
Message, a typed dictionary (based on the response from OpenAI API)
chaincrafter.experiments
ExperimentExperiment(chain: Chain, **model_params)set_chain_starting_input_vars(starting_input_vars: dict)prepare()run(runs: int = 1)to_csv()to_pandas_df()to_json()visualize()
OpenAiChatExperiment(Experiment)
chaincrafter.models
ChatModelChatModel(temperature: float, model_name: str)complete(messages: [dict]) -> strshow_usage()
MockChat(ChatModel)MockChat(temperature: float, model_name: str)mock_responses(messages: [dict])complete(messages: [dict])
OpenAiChat(ChatModel)OpenAiChat(temperature: float, model_name: str, top_p: float, n: int, stream: bool, stop: [str], max_tokens: int, presence_penalty: float, frequency_penalty: float, logit_bias: dict): same API as OpenAI APIcomplete(messages: [dict])show_usage()
chaincrafter.prompts
PromptPrompt(fmt_str: str, prompt_modifiers: [Callable], **input_vars_transformers: [dict[str, Callable]])build(**input_vars: dict) -> str
response_format_list(example_item_text: str) -> Callable[[str], str]response_style(style_of: str) -> strresponse_length(short_or_long: str = "short", answer_or_paragraph: str = "sentence") -> strextract_items_from_list(response: str) -> [str]
JavaScript/TypeScript
work in progress
Catalog Format YAML
YAML file format for Catalogs:
prompts:
helpful_assistant: You are a helpful assistant
initial_code_review: |
I just put a lot of work into this code, can you please review it and offer suggestions for improvement? Do not write any code.
```
{diff}
```
city_population: "{city} sounds like a nice place to visit. What is the population of {city}?"
chains:
example:
- helpful_assistant:
- initial_code_review: city
- city_population: output