langchain/libs/experimental/langchain_experimental/synthetic_data/prompts.py
Mateusz Wosinski a29cd89923
Synthetic data generation (#9759)
### Description

Implements synthetic data generation with the fields and preferences
given by the user. Adds showcase notebook.
Corresponding prompt was proposed for langchain-hub.

### Example

```
output = chain({"fields": {"colors": ["blue", "yellow"]}, "preferences": {"style": "Make it in a style of a weather forecast."}})
print(output)

# {'fields': {'colors': ['blue', 'yellow']},
 'preferences': {'style': 'Make it in a style of a weather forecast.'},
 'text': "Good morning! Today's weather forecast brings a beautiful combination of colors to the sky, with hues of blue and yellow gently blending together like a mesmerizing painting."}
```

### Twitter handle 

@deepsense_ai @matt_wosinski

---------

Co-authored-by: Bagatur <baskaryan@gmail.com>
2023-09-19 16:29:50 -07:00

16 lines
459 B
Python

from langchain.prompts.prompt import PromptTemplate
sentence_template = """Given the following fields, create a sentence about them.
Make the sentence detailed and interesting. Use every given field.
If any additional preferences are given, use them during sentence construction as well.
Fields:
{fields}
Preferences:
{preferences}
Sentence:
"""
SENTENCE_PROMPT = PromptTemplate(
template=sentence_template, input_variables=["fields", "preferences"]
)